Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

taymoor89
Copy link
Contributor

Summary

This PR add an ADR for client-side routing so other apps can add routing based on the same principals.

Changes Made

  • Created an ADR in docs

Related Issues

Screenshots (if applicable)

Testing Instructions

  1. pnpm i
  2. pnpm TASK

Checklist

  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have made corresponding changes to the documentation (if applicable).
  • My changes generate no new warnings or errors.
  • I have created a changeset for my changes.

PR Manifesto

Review the PR Manifesto for best practises.

@taymoor89 taymoor89 self-assigned this Jun 25, 2025
@taymoor89 taymoor89 added the documentation Improvements or additions to documentation label Jun 25, 2025
Copy link

changeset-bot bot commented Jun 25, 2025

⚠️ No Changeset found

Latest commit: b0eb0d4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@taymoor89 taymoor89 marked this pull request as ready for review June 25, 2025 14:48
@taymoor89 taymoor89 requested a review from a team as a code owner June 25, 2025 14:48
andypf
andypf previously approved these changes Jun 25, 2025
Copy link
Collaborator

@andypf andypf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

hodanoori
hodanoori previously approved these changes Jun 26, 2025
Copy link
Contributor

@hodanoori hodanoori left a 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

TilmanHaupt
TilmanHaupt previously approved these changes Jun 26, 2025

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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:

  1. 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.
  2. Improved readability: The query-string library provides a more human-readable URL format compared to the default JSON.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).
  3. Centralized control: Exposing the utility through url-state-provider lets us control the query-string version and apply sensible, consistent defaults across the app.

Copy link
Contributor

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

@taymoor89 taymoor89 dismissed stale reviews from TilmanHaupt, hodanoori, and andypf via ca48fd3 June 30, 2025 08:22
Copy link
Collaborator

@ArtieReus ArtieReus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@hodanoori hodanoori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@edda edda left a 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:

  1. 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
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants