-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): site storage config options (experimental) #10121
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: +687 B (+0.04%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
This was referenced Jun 22, 2024
This was referenced Jun 22, 2024
This was referenced Sep 13, 2024
This was referenced Sep 28, 2024
This was referenced Sep 29, 2024
Closed
This was referenced Oct 4, 2024
This was referenced Oct 19, 2024
Open
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This introduces new site config options to let users control the default browser storage behavior of a Docusaurus site.
Note: our themes respect that config, but third-party themes are not forced to, and it's only a default that can be ignored on a case-by-case basis.
It is useful to apply a namespace to browser storage keys, to avoid storage key conflicts on the same domain:
http://localhost:3000
)/baseUrl/
(https://example.com/site1/
+https://example.com/site2/
). This is notably the case at Meta.While we work on this, it's also a good opportunity to let users decide between
localStorage
orsessionStorage
for browser persistence.For retro-compatibility reasons, we can't apply a namespace by default in v3, so it has to be turned on through options.
This is a good opportunity for Docusaurus to introduce Future Flags similar to what the Remix framework does. We can ship opt-in breaking changes that we might turn on by default on upcoming major versions.
The config for this new feature:
For convenience, it's possible to use
config.future.experimental_storage.namespace = true
.In this case, we'll compute a 3-char hash based on your
https://siteUrl.com/baseUrl/siteUrl/
(ie yourtheme
storage key becometheme-x7j
)We may turn this on by default in Docusaurus v4 (breaking change), with an option to revert.
For now, this API is experimental until we get feedback from internal usage at Meta. We might refactor it in minor versions according to feedback.
Test Plan
CI + preview + internal rollout at Meta
When namespacing is on, storage keys should have a suffix:
Test links
https://deploy-preview-10121--docusaurus-2.netlify.app/
Migration strategy
The default/classic Docusaurus theme stores the following keys in localStorage:
It shouldn't be a big deal to have these stored values being reset, but if you want to turn on storage namspacing without disrupting the user experience, you can migrate storage keys with a client module script like this one:
Note that: