generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
# Max Safe URL Length Exceeded | ||
|
||
This error occurs if your URI length exceeds 2,000 | ||
characters, there are varying browser limitations | ||
for max URL lengths. | ||
This error occurs if your URL length exceeds 2,000 characters. | ||
|
||
See [here](https://nuqs.47ng.com/docs/limits#max-url-lengths) for URL max lengths across different browsers. | ||
There are varying browser limitations for max URL lengths, [read more](https://nuqs.47ng.com/docs/limits#max-url-lengths). | ||
|
||
URLs that are too long might break in some browsers, or not be able to be | ||
processed by some servers. | ||
|
||
## Possible Solutions | ||
|
||
Refactor your state architecture to ensure your total | ||
URL length doesn't exceed 2,000 characters. | ||
Keeping your URLs short is a good practice: not all state has to live in the URL. | ||
|
||
- Server state/data is best managed in a local cache like TanStack Query or SWR. | ||
- Transient state (that doesn't need persisting or sharing) can be managed in local state. | ||
- Device-persistent state can be managed in local storage. | ||
|
||
When deciding to put state in the URL, ask yourself: | ||
|
||
- Do I need it to persist across page refresh? | ||
- Do I need to share it with others? | ||
- Do I need to link to it from other places? | ||
- Do I need to be able to bookmark it? | ||
- Do I need to be able to use the Back/Forward buttons to navigate to it? | ||
- Is it always going to be a small amount of data? | ||
|
||
If the answer to any of these questions is no, then you might want to consider | ||
an alternative state storage solution. |