-
Notifications
You must be signed in to change notification settings - Fork 0
chore(docs): create ADR for client-side routing #1033
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
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for preparing this ADR
|
||
4. **URL State Encoding/Decoding**: | ||
|
||
- We utilize the `v2/encode` and `v2/decode` utilities from the `url-state-provider` package to handle query string parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need our custom encoding, url-state-provider and do not use default SearchParams from Tanstack.
What is the use case for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently, we introduced v2 of the encoding/decoding utilities in url-state-provider
. These utilities are essentially thin wrappers around the query-string
library (which, by the way, is also referenced in the official TanStack Router docs). By default, TanStack uses JSON.stringify
for URL serialization.
You might wonder: If we can use query-string
directly with TanStack Router, why expose it through url-state-provider
?
Here are the key reasons:
- Consistent flat structure: We want application developers to persist state to the URL in a flat format—not deeply nested. Arrays of primitive values are allowed, but complex nested collections are not.
- Improved readability: The
query-string
library provides a more human-readable URL format compared to the defaultJSON.stringify
output. For example we can put arrays strings in a nicely comma separated form in the URL which is human readable(filters are a very good use-case of it). - Centralized control: Exposing the utility through
url-state-provider
lets us control thequery-string
version and apply sensible, consistent defaults across the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taymoor89 I like the detailed explanation. I would propose to add this (maybe as a footnote) to the ADR itself so it doesn't get lost
ca48fd3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I like it!
Two things I would propose:
- add the info form your comment with the justification for the encode/decode utility to the ADR itself. I think it's very valuable additional information that helps understand the decision. Also a simple example of what encode and decode does could help
- Section 5. Route Definitions and UI State: a couple of examples would help understand this better, imo. So give an example for one or two routes coming out of the file-based routing, then give an example how they would change with an opened panel or modal.
Summary
This PR add an ADR for client-side routing so other apps can add routing based on the same principals.
Changes Made
Related Issues
Screenshots (if applicable)
Testing Instructions
pnpm i
pnpm TASK
Checklist
PR Manifesto
Review the PR Manifesto for best practises.