Skip to content

Docs: Update search parameters guide for zod v4#6956

Open
robballou wants to merge 4 commits intoTanStack:mainfrom
robballou:docs/update-search-params-for-zod4
Open

Docs: Update search parameters guide for zod v4#6956
robballou wants to merge 4 commits intoTanStack:mainfrom
robballou:docs/update-search-params-for-zod4

Conversation

@robballou
Copy link

@robballou robballou commented Mar 17, 2026

Zod v4 does not require use of the adapter and can use the schemas directly. See #4322

Summary by CodeRabbit

  • Documentation
    • Clarified Zod v3 vs Zod v4 guidance across search-params docs, specifying when to use the adapter versus direct Zod schemas.
    • Updated all examples and guides to prefer direct-schema validateSearch for Zod v4 (removed adapter wrappers in examples), adjusted default/.catch vs fallback recommendations, and refreshed step-by-step, inheritance, Link, and catch/fallback guidance to match the new patterns.

Zod v4 does not require use of the adapter and can use the schemas directly. See TanStack#4322
@github-actions github-actions bot added the documentation Everything documentation related label Mar 17, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Documentation updated to replace zod-adapter wrapper usage with direct Zod v4 schema examples for validateSearch while retaining adapter guidance for Zod v3. Examples, notes, and schemas across guides, API docs, how-tos, and migration skills now show validateSearch accepting raw Zod schemas and clarify .catch/.default vs fallback differences.

Changes

Cohort / File(s) Summary
Search Params Guide
docs/router/guide/search-params.md
Added explicit Zod v3 vs v4 guidance; show zodValidator for v3 and direct schema usage for v4; expanded examples and clarified .catch vs fallback behavior and typing.
Router API docs
docs/router/api/router/retainSearchParamsFunction.md, docs/router/api/router/stripSearchParamsFunction.md
Replaced example validateSearch: zodValidator(searchSchema) with validateSearch: searchSchema; removed adapter imports in examples and annotated Zod v4 usage in route config snippets.
How-to guides
docs/router/how-to/setup-basic-search-params.md, docs/router/how-to/validate-search-params.md, docs/router/how-to/share-search-params-across-routes.md
Converted examples to direct Zod schemas for validateSearch; removed adapter/fallback patterns for Zod v4 examples; updated schemas to use .default/.catch; reflowed narrative and code patterns.
Skills / Migration docs
packages/react-router/skills/lifecycle/migrate-from-react-router/SKILL.md, packages/router-core/skills/router-core/search-params/SKILL.md
Removed zod-adapter imports in examples; switched route examples to direct schema validateSearch; added clear guidance for Zod v3 (adapter/fallback) vs Zod v4 (direct schema / .catch).
Doc example route files
routes/__root.tsx, routes/products/index.tsx, routes/_authenticated.tsx, src/routes/...
Example route configs updated to set validateSearch to raw Zod schemas (e.g., globalSearchSchema, productSearchSchema) instead of zodValidator(...); several inline schema examples converted to z.object({ ... }).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through docs at dawn’s first light,

Swapped cloaks for schemas, clean and bright.
V3 keeps its adapter, V4 sings free,
Search params sorted — a carrot of glee. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the primary objective of the PR—updating search parameters documentation to reflect Zod v4 compatibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@robballou
Copy link
Author

Additional question, there are 12 other files which mention the zodAdapter: should those also be updated?

@birkskyum
Copy link
Member

Additional question, there are 12 other files which mention the zodAdapter: should those also be updated?

@robballou Yes, that would be good to get everything modernized.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Bundle Size Benchmarks

  • Commit: 3b8ab0fa6bd6
  • Measured at: 2026-03-18T16:06:39.170Z
  • Baseline source: history:6651473d028a
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.61 KiB 0 B (0.00%) 276.07 KiB 76.12 KiB ▁▁▁▁▁▁▁████
react-router.full 90.65 KiB 0 B (0.00%) 286.28 KiB 78.68 KiB ▁▁▁▁▁▁▁████
solid-router.minimal 37.14 KiB 0 B (0.00%) 111.38 KiB 33.29 KiB ▁▁▁▁▁▁▁████
solid-router.full 41.36 KiB 0 B (0.00%) 124.18 KiB 37.12 KiB ▁▁▁▁▁▁▁████
vue-router.minimal 52.99 KiB 0 B (0.00%) 151.41 KiB 47.65 KiB ▁▁▁▁▁▁▁████
vue-router.full 57.69 KiB 0 B (0.00%) 166.34 KiB 51.60 KiB ▁▁▁▁▁▁▁████
react-start.minimal 101.99 KiB 0 B (0.00%) 324.08 KiB 88.20 KiB ▁▁▁▁▁▁▁████
react-start.full 105.33 KiB 0 B (0.00%) 333.89 KiB 91.02 KiB ▁▁▁▁▁▁▁████
solid-start.minimal 51.24 KiB 0 B (0.00%) 157.82 KiB 45.28 KiB ▁▁▁▁▁▁▁████
solid-start.full 56.53 KiB 0 B (0.00%) 173.32 KiB 49.72 KiB ▁▁▁▁▁▁▁████

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@nx-cloud
Copy link

nx-cloud bot commented Mar 18, 2026

View your CI Pipeline Execution ↗ for commit 0451f0d

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 33s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-18 15:24:04 UTC

@robballou
Copy link
Author

I have updated more of the documentation while hopefully retaining the value. I am trying to give both v3 and v4 examples where it seems appropriate. In a few places, I replaced the instructions with Zod v4 only as it seems new projects would use v4.

Notes:

  • Some of these changes are within LLM skills it seems like, but I have not validated that those work.
  • I left the zodAdapter use for Start's inputValidation because I am unsure if how that works. Since the @tanstack/zod-adapter only works with Zod v3, I assume something needs to be updated in the documentation.
  • I did try some variations in of using the schema directly in a local project to see that they worked as expected, but not all examples were tested by me 😆

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/router/how-to/setup-basic-search-params.md (2)

103-103: 🛠️ Refactor suggestion | 🟠 Major

Remove unused fallback import after v4 migration.

Line 103 imports fallback from @tanstack/zod-adapter, but after the v4 updates, all examples in this section now use .default() instead of fallback(). This import is no longer used and should be removed to avoid confusion.

🧹 Proposed fix to remove unused import
 import { z } from 'zod'
-import { fallback } from '@tanstack/zod-adapter'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/router/how-to/setup-basic-search-params.md` at line 103, Remove the
now-unused fallback import from `@tanstack/zod-adapter`: delete the import
statement that includes "fallback" (the line "import { fallback } from
'@tanstack/zod-adapter'") and verify examples in this document use .default()
instead—ensure there are no remaining references to the fallback symbol in the
section so the import can be fully removed.

15-22: ⚠️ Potential issue | 🟠 Major

Quick start example mixes Zod v3 and v4 patterns inconsistently.

The schema definition (lines 15-19) uses fallback() from the Zod adapter:

page: fallback(z.number(), 1).default(1),
category: fallback(z.string(), 'all').default('all'),
showSale: fallback(z.boolean(), false).default(false),

But line 22 uses the schema directly without the adapter wrapper:

validateSearch: productSearchSchema,  // No zodValidator() wrapper

This combination won't work because:

  1. fallback() requires @tanstack/zod-adapter to be installed
  2. Users following the v4 guidance won't have the adapter package
  3. The pattern contradicts the v4 examples shown later (lines 54-68)
🔄 Proposed fix to use pure Zod v4 syntax
 const productSearchSchema = z.object({
-  page: fallback(z.number(), 1).default(1),
-  category: fallback(z.string(), 'all').default('all'),
-  showSale: fallback(z.boolean(), false).default(false),
+  page: z.number().default(1),
+  category: z.string().default('all'),
+  showSale: z.boolean().default(false),
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/router/how-to/setup-basic-search-params.md` around lines 15 - 22, The
example mixes the Zod adapter's fallback() with an unwrapped schema; replace
fallback(...) usages in productSearchSchema with pure Zod v4 forms (e.g.,
z.coerce.number().default(1), z.coerce.string().default('all'),
z.coerce.boolean().default(false)) so the schema is standalone, and then pass it
into createFileRoute using the zodValidator wrapper (validateSearch:
zodValidator(productSearchSchema)) to match v4 patterns and remove the
dependency on `@tanstack/zod-adapter`.
🧹 Nitpick comments (1)
docs/router/how-to/validate-search-params.md (1)

220-222: Consider adding version labels to fallback() examples.

Several code examples throughout the guide continue using the fallback() helper (lines 220, 341, 421, 434, 538, 576) without indicating whether they're Zod v3 or v4 examples. Since the quick start and dedicated sections now clearly distinguish v3 vs v4, these examples may confuse users about which pattern to follow.

Consider either:

  1. Converting these to Zod v4 syntax (.default() and .catch())
  2. Adding comments like // Zod v3 pattern where fallback() is used
  3. Providing both v3 and v4 versions in these pattern sections

Also applies to: 340-346, 421-423, 538-539, 576-577

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/router/how-to/validate-search-params.md` around lines 220 - 222, The
docs use the Zod helper fallback() in multiple examples (e.g., the page:
fallback(...), limit: fallback(...)) without indicating whether these are Zod v3
or v4 patterns; update those examples by either converting them to Zod v4
equivalents using .default() and .catch(), or add inline comments like "// Zod
v3 pattern" next to fallback() usages, or provide both versions side-by-side so
readers can see fallback() (v3) and the .default()/.catch() (v4) alternatives;
apply this change consistently for all occurrences of fallback() in these
examples to avoid ambiguity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/router-core/skills/router-core/search-params/SKILL.md`:
- Around line 49-50: The code example is missing the fallback import used by
fallback() in the snippet; update the example's imports to include fallback
(e.g., add an import for fallback alongside other imports) so the call to
fallback() used with validateSearch, productSearchSchema, and component:
ProductsPage resolves correctly; ensure the imported symbol name is exactly
fallback to match its usage in the example.

---

Outside diff comments:
In `@docs/router/how-to/setup-basic-search-params.md`:
- Line 103: Remove the now-unused fallback import from `@tanstack/zod-adapter`:
delete the import statement that includes "fallback" (the line "import {
fallback } from '@tanstack/zod-adapter'") and verify examples in this document
use .default() instead—ensure there are no remaining references to the fallback
symbol in the section so the import can be fully removed.
- Around line 15-22: The example mixes the Zod adapter's fallback() with an
unwrapped schema; replace fallback(...) usages in productSearchSchema with pure
Zod v4 forms (e.g., z.coerce.number().default(1),
z.coerce.string().default('all'), z.coerce.boolean().default(false)) so the
schema is standalone, and then pass it into createFileRoute using the
zodValidator wrapper (validateSearch: zodValidator(productSearchSchema)) to
match v4 patterns and remove the dependency on `@tanstack/zod-adapter`.

---

Nitpick comments:
In `@docs/router/how-to/validate-search-params.md`:
- Around line 220-222: The docs use the Zod helper fallback() in multiple
examples (e.g., the page: fallback(...), limit: fallback(...)) without
indicating whether these are Zod v3 or v4 patterns; update those examples by
either converting them to Zod v4 equivalents using .default() and .catch(), or
add inline comments like "// Zod v3 pattern" next to fallback() usages, or
provide both versions side-by-side so readers can see fallback() (v3) and the
.default()/.catch() (v4) alternatives; apply this change consistently for all
occurrences of fallback() in these examples to avoid ambiguity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09ff36d7-7b3b-416a-bee9-8f183d8eccd3

📥 Commits

Reviewing files that changed from the base of the PR and between abfda7b and fc49018.

📒 Files selected for processing (7)
  • docs/router/api/router/retainSearchParamsFunction.md
  • docs/router/api/router/stripSearchParamsFunction.md
  • docs/router/how-to/setup-basic-search-params.md
  • docs/router/how-to/share-search-params-across-routes.md
  • docs/router/how-to/validate-search-params.md
  • packages/react-router/skills/lifecycle/migrate-from-react-router/SKILL.md
  • packages/router-core/skills/router-core/search-params/SKILL.md

Comment on lines +49 to 50
validateSearch: productSearchSchema,
component: ProductsPage,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify markdown code blocks that call fallback(...) without importing it.
python - <<'PY'
import re, pathlib

targets = [
    pathlib.Path("packages/router-core/skills/router-core/search-params/SKILL.md"),
    pathlib.Path("packages/react-router/skills/lifecycle/migrate-from-react-router/SKILL.md"),
]

fence_re = re.compile(r"```(?:tsx|ts|js|jsx|python|bash)?\n(.*?)\n```", re.S)

for p in targets:
    text = p.read_text(encoding="utf-8")
    blocks = fence_re.findall(text)
    for i, b in enumerate(blocks, 1):
        if "fallback(" in b and "@tanstack/zod-adapter" not in b:
            print(f"{p} :: code block #{i} uses fallback(...) without adapter import")
PY

Repository: TanStack/router

Length of output: 180


🏁 Script executed:

# Read the file to see the code block context and verify line numbers
head -60 packages/router-core/skills/router-core/search-params/SKILL.md | tail -30

Repository: TanStack/router

Length of output: 794


🏁 Script executed:

# Check if fallback is exported from `@tanstack/zod-adapter`
fd -e ts -e js "zod-adapter" packages/ | head -5

Repository: TanStack/router

Length of output: 41


🏁 Script executed:

# Search for zod-adapter references in the codebase
rg "@tanstack/zod-adapter" --type md -A 2 | head -20

Repository: TanStack/router

Length of output: 1739


Add missing fallback import to the code example.

The code block uses fallback() on lines 41–43 but doesn't import it. The import statement is missing:

 import { createFileRoute } from '@tanstack/react-router'
 import { z } from 'zod'
+import { fallback } from '@tanstack/zod-adapter'

This import appears correctly in another example in the same file; it needs to be added here for the code snippet to be functional when copied.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/router-core/skills/router-core/search-params/SKILL.md` around lines
49 - 50, The code example is missing the fallback import used by fallback() in
the snippet; update the example's imports to include fallback (e.g., add an
import for fallback alongside other imports) so the call to fallback() used with
validateSearch, productSearchSchema, and component: ProductsPage resolves
correctly; ensure the imported symbol name is exactly fallback to match its
usage in the example.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@6956

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@6956

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@6956

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@6956

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@6956

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@6956

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@6956

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@6956

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@6956

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@6956

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@6956

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@6956

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@6956

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@6956

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@6956

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@6956

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@6956

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@6956

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@6956

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@6956

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@6956

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@6956

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@6956

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@6956

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@6956

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@6956

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@6956

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@6956

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@6956

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@6956

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@6956

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@6956

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@6956

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@6956

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@6956

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@6956

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@6956

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@6956

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@6956

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@6956

commit: 0451f0d

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/router/how-to/setup-basic-search-params.md (1)

11-19: ⚠️ Potential issue | 🟠 Major

Quick Start snippet is non-runnable: fallback() is used without being imported.

The Quick Start code at lines 11-19 references fallback() but imports only z from zod. Later sections in the file promote Zod v4 direct schema validation. Update this snippet to use native Zod v4 syntax (.default() and .catch()) so users can copy and run it immediately.

Proposed fix (align with Zod v4 native approach)
 import { createFileRoute } from '@tanstack/react-router'
 import { z } from 'zod'
 
 const productSearchSchema = z.object({
-  page: fallback(z.number(), 1).default(1),
-  category: fallback(z.string(), 'all').default('all'),
-  showSale: fallback(z.boolean(), false).default(false),
+  page: z.number().default(1).catch(1),
+  category: z.string().default('all').catch('all'),
+  showSale: z.boolean().default(false).catch(false),
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/router/how-to/setup-basic-search-params.md` around lines 11 - 19, The
snippet uses the non-imported fallback() helper in productSearchSchema; replace
those calls with native Zod v4 patterns so the snippet is runnable — for example
change page: fallback(z.number(), 1).default(1) to page:
z.number().catch(1).default(1), category: fallback(z.string(),
'all').default('all') to category: z.string().catch('all').default('all'), and
showSale: fallback(z.boolean(), false).default(false) to showSale:
z.boolean().catch(false).default(false); keep the existing import of z from
'zod' and update only the productSearchSchema definition.
♻️ Duplicate comments (1)
packages/router-core/skills/router-core/search-params/SKILL.md (1)

35-43: ⚠️ Potential issue | 🟠 Major

Adapter setup example is still broken and mixed-mode (duplicate of prior finding).

This snippet still uses fallback(...) without importing it, and the section title says “Zod Adapter (Recommended)” while the route uses direct schema assignment. Please make the example consistently adapter-based or rename/rewrite it as v4 direct-schema guidance.

If keeping this section adapter-based, use this fix
 // src/routes/products.tsx
 import { createFileRoute } from '@tanstack/react-router'
 import { z } from 'zod'
+import { fallback, zodValidator } from '@tanstack/zod-adapter'
@@
 export const Route = createFileRoute('/products')({
-  validateSearch: productSearchSchema,
+  validateSearch: zodValidator(productSearchSchema),
   component: ProductsPage,
 })

Also applies to: 49-49

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/router-core/skills/router-core/search-params/SKILL.md` around lines
35 - 43, The example under "Zod Adapter (Recommended)" is inconsistent:
productSearchSchema uses fallback(...) without importing it and the route uses a
direct schema instead of the adapter; fix by either (A) making this a proper
adapter example—rename the section if you want to keep direct schema, or rewrite
the snippet to use the Zod search-params adapter API and pass a zod schema
through that adapter (replace direct usage of productSearchSchema in
createFileRoute with the adapter-based call), or (B) if you intend to show the
v4 direct-schema approach, remove the adapter title and import fallback (and any
other helpers) so productSearchSchema compiles; ensure the symbols
productSearchSchema, fallback, createFileRoute and any adapter helper you choose
are present and used consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/router/how-to/setup-basic-search-params.md`:
- Line 95: Remove the unused `fallback` import from the Step 1 example: locate
the import that brings in the Zod v4 adapter and remove the `fallback` specifier
(or the entire adapter import if it only exported `fallback`), leaving only the
native Zod v4 usage that relies on `.default()`; ensure the example imports
exactly the symbols it uses so there are no unused imports.

---

Outside diff comments:
In `@docs/router/how-to/setup-basic-search-params.md`:
- Around line 11-19: The snippet uses the non-imported fallback() helper in
productSearchSchema; replace those calls with native Zod v4 patterns so the
snippet is runnable — for example change page: fallback(z.number(),
1).default(1) to page: z.number().catch(1).default(1), category:
fallback(z.string(), 'all').default('all') to category:
z.string().catch('all').default('all'), and showSale: fallback(z.boolean(),
false).default(false) to showSale: z.boolean().catch(false).default(false); keep
the existing import of z from 'zod' and update only the productSearchSchema
definition.

---

Duplicate comments:
In `@packages/router-core/skills/router-core/search-params/SKILL.md`:
- Around line 35-43: The example under "Zod Adapter (Recommended)" is
inconsistent: productSearchSchema uses fallback(...) without importing it and
the route uses a direct schema instead of the adapter; fix by either (A) making
this a proper adapter example—rename the section if you want to keep direct
schema, or rewrite the snippet to use the Zod search-params adapter API and pass
a zod schema through that adapter (replace direct usage of productSearchSchema
in createFileRoute with the adapter-based call), or (B) if you intend to show
the v4 direct-schema approach, remove the adapter title and import fallback (and
any other helpers) so productSearchSchema compiles; ensure the symbols
productSearchSchema, fallback, createFileRoute and any adapter helper you choose
are present and used consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7dc78b3-797a-4111-a8bb-fde236bde6e8

📥 Commits

Reviewing files that changed from the base of the PR and between fc49018 and 0451f0d.

📒 Files selected for processing (3)
  • docs/router/how-to/setup-basic-search-params.md
  • packages/react-router/skills/lifecycle/migrate-from-react-router/SKILL.md
  • packages/router-core/skills/router-core/search-params/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-router/skills/lifecycle/migrate-from-react-router/SKILL.md

## Step-by-Step Setup with Zod

The rest of this guide uses Zod for examples, but the patterns apply to any validation library.
The rest of this guide uses Zod v4 for examples, but the patterns apply to any validation library.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n docs/router/how-to/setup-basic-search-params.md | head -120 | tail -40

Repository: TanStack/router

Length of output: 1472


🏁 Script executed:

cat -n docs/router/how-to/setup-basic-search-params.md | sed -n '120,180p'

Repository: TanStack/router

Length of output: 1789


🏁 Script executed:

cat -n docs/router/how-to/setup-basic-search-params.md | sed -n '180,250p'

Repository: TanStack/router

Length of output: 2176


🏁 Script executed:

cat -n docs/router/how-to/setup-basic-search-params.md | sed -n '250,350p'

Repository: TanStack/router

Length of output: 3740


Remove unused fallback import from Step 1 example.

The Step 1 code imports the Zod v4 adapter but doesn't use it—the example correctly uses native Zod v4 .default() syntax instead. Remove the import to keep the example clean and consistent with the stated v4 approach.

Proposed fix
 import { z } from 'zod'
-import { fallback } from '@tanstack/zod-adapter'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/router/how-to/setup-basic-search-params.md` at line 95, Remove the
unused `fallback` import from the Step 1 example: locate the import that brings
in the Zod v4 adapter and remove the `fallback` specifier (or the entire adapter
import if it only exported `fallback`), leaving only the native Zod v4 usage
that relies on `.default()`; ensure the example imports exactly the symbols it
uses so there are no unused imports.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 3 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing robballou:docs/update-search-params-for-zod4 (0451f0d) with main (6651473)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (3b8ab0f) during the generation of this report, so 6651473 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/router-core/skills/router-core/search-params/SKILL.md (1)

41-43: Section framing is inconsistent with the updated Zod v4 example.

Lines 41–45 and Line 49 now correctly show Zod v4 direct-schema usage, but this section still reads as adapter-first setup. That contradiction can mislead readers on what to install/use first.

Suggested docs adjustment
-## Setup: Zod Adapter (Recommended)
+## Setup: Zod v4 (Recommended)

 ```bash
-npm install zod `@tanstack/zod-adapter`
+npm install zod

+For Zod v3 projects, use @tanstack/zod-adapter with zodValidator() and fallback().

</details>


Also applies to: 45-45, 49-49

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @packages/router-core/skills/router-core/search-params/SKILL.md around lines
41 - 43, Update the inconsistent docs section in SKILL.md to reflect Zod v4
usage by changing the install command to "npm install zod" and framing examples
as direct Zod v4 schema usage (e.g., z.number(), z.enum(), etc.); additionally
add a short note that projects still on Zod v3 should install and use
@tanstack/zod-adapter and the adapter helpers zodValidator() and fallback()
instead, ensuring the section consistently matches the examples elsewhere that
show direct-schema usage.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @packages/router-core/skills/router-core/search-params/SKILL.md:

  • Around line 41-43: Update the inconsistent docs section in SKILL.md to reflect
    Zod v4 usage by changing the install command to "npm install zod" and framing
    examples as direct Zod v4 schema usage (e.g., z.number(), z.enum(), etc.);
    additionally add a short note that projects still on Zod v3 should install and
    use @tanstack/zod-adapter and the adapter helpers zodValidator() and fallback()
    instead, ensuring the section consistently matches the examples elsewhere that
    show direct-schema usage.

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro

**Run ID**: `cb5d702b-05b5-4fcc-af5c-8f49790aef95`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 0451f0d2d58e2cfca015b63e52085cf37dc0262b and 5c7ffb5c56b64b3ab3cf3f8ebf098b80f0567031.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `packages/router-core/skills/router-core/search-params/SKILL.md`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants