Skip to content

Commit 8981f46

Browse files
ci: apply automated fixes
1 parent 3ac2cdc commit 8981f46

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/blog/search-params-are-state.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ authors:
77

88
![Search Params Are State Header](/blog-assets/search-params-are-state/search-params-are-state-header.jpg)
99

10-
## Search Params Are State . Treat Them That Way
10+
## Search Params Are State . Treat Them That Way
1111

12-
Search params have been historically treated like second-class state. They're global, serializable, and shareable . but in most apps, they’re still hacked together with string parsing, loose conventions, and brittle utils.
12+
Search params have been historically treated like second-class state. They're global, serializable, and shareable . but in most apps, they’re still hacked together with string parsing, loose conventions, and brittle utils.
1313

1414
Even something simple, like validating a `sort` param, quickly turns verbose:
1515

@@ -30,7 +30,7 @@ This works, but it’s manual and repetitive. There’s no inference, no connect
3030

3131
Even worse, `URLSearchParams` is string-only. It doesn’t support nested JSON, arrays (beyond naive comma-splitting), or type coercion. So unless your state is flat and simple, you’re going to hit walls fast.
3232

33-
That’s why we’re starting to see a rise in tools and proposals . things like Nuqs, Next.js RFCs, and userland patterns . aimed at making search params more type-safe and ergonomic. Most of these focus on improving _reading_ from the URL.
33+
That’s why we’re starting to see a rise in tools and proposals . things like Nuqs, Next.js RFCs, and userland patterns . aimed at making search params more type-safe and ergonomic. Most of these focus on improving _reading_ from the URL.
3434

3535
But almost none of them solve the deeper, harder problem: **writing** search params, safely and atomically, with full awareness of routing context.
3636

@@ -56,15 +56,15 @@ Constraint is what makes coordination possible. It’s what allows **non-local c
5656

5757
---
5858

59-
### Local Abstractions Can Help . But They Don’t Coordinate
59+
### Local Abstractions Can Help . But They Don’t Coordinate
6060

61-
Tools like **Nuqs** are a great example of how local abstractions can improve the _ergonomics_ of search param handling. You get Zod-powered parsing, type inference, even writable APIs . all scoped to a specific component or hook.
61+
Tools like **Nuqs** are a great example of how local abstractions can improve the _ergonomics_ of search param handling. You get Zod-powered parsing, type inference, even writable APIs . all scoped to a specific component or hook.
6262

63-
They make it easier to read and write search params **in isolation** . and that’s valuable.
63+
They make it easier to read and write search params **in isolation** . and that’s valuable.
6464

6565
But they don’t solve the broader issue of **coordination**. You still end up with duplicated schemas, disjointed expectations, and no way to enforce consistency between routes or components. Defaults can conflict. Types can drift. And when routes evolve, nothing guarantees all the callers update with them.
6666

67-
That’s the real fragmentation problem . and fixing it requires bringing search param schemas into the routing layer itself.
67+
That’s the real fragmentation problem . and fixing it requires bringing search param schemas into the routing layer itself.
6868

6969
---
7070

@@ -100,13 +100,13 @@ navigate({
100100
})
101101
```
102102

103-
It’s reducer-style, transactional, and integrates directly with the router’s reactivity model. Components only re-render when the specific search param they use changes . not every time the URL mutates.
103+
It’s reducer-style, transactional, and integrates directly with the router’s reactivity model. Components only re-render when the specific search param they use changes . not every time the URL mutates.
104104

105105
---
106106

107107
### How TanStack Router Prevents Schema Fragmentation
108108

109-
When your search param logic lives in userland . scattered across hooks, utils, and helpers . it’s only a matter of time before you end up with **conflicting schemas**.
109+
When your search param logic lives in userland . scattered across hooks, utils, and helpers . it’s only a matter of time before you end up with **conflicting schemas**.
110110

111111
Maybe one component expects \`sort: 'asc' | 'desc'\`. Another adds a \`filter\`. A third assumes \`sort: 'desc'\` by default. None of them share a source of truth.
112112

@@ -117,7 +117,7 @@ This leads to:
117117
- Navigation that sets values others can’t parse
118118
- Broken deep linking and bugs you can’t trace
119119

120-
TanStack Router prevents this by tying schemas directly to your route definitions . **hierarchically**.
120+
TanStack Router prevents this by tying schemas directly to your route definitions . **hierarchically**.
121121

122122
Parent routes can define shared search param validation. Child routes inherit that context, add to it, or extend it in type-safe ways. This makes it _impossible_ to accidentally create overlapping, incompatible schemas in different parts of your app.
123123

@@ -160,23 +160,23 @@ validateSearch: z.object({
160160
})
161161
```
162162

163-
This kind of enforcement makes nested routes composable _and_ safe . a rare combo.
163+
This kind of enforcement makes nested routes composable _and_ safe . a rare combo.
164164

165165
---
166166

167167
### Built-In Discipline
168168

169169
The magic here is that you don’t need to teach your team to follow conventions. The route _owns_ the schema. Everyone just uses it. There’s no duplication. No drift. No silent bugs. No guessing.
170170

171-
When you bring validation, typing, and ownership into the router itself, you stop treating URLs like strings and start treating them like real state . because that’s what they are.
171+
When you bring validation, typing, and ownership into the router itself, you stop treating URLs like strings and start treating them like real state . because that’s what they are.
172172

173173
---
174174

175175
### Search Params Are State
176176

177177
Most routing systems treat search params like an afterthought. Something you _can_ read, maybe parse, maybe stringify, but rarely something you can actually **trust**.
178178

179-
TanStack Router flips that on its head. It makes search params a core part of the routing contract . validated, inferable, writable, and reactive.
179+
TanStack Router flips that on its head. It makes search params a core part of the routing contract . validated, inferable, writable, and reactive.
180180

181181
Because if you’re not treating search params like state, you’re going to keep leaking it, breaking it, and working around it.
182182

0 commit comments

Comments
 (0)