Skip to content

Conversation

@timneutkens
Copy link
Member

@timneutkens timneutkens commented Jan 12, 2026

Description

This PR adds dedicated documentation pages for useSearchParams and useParams hooks in the Pages Router documentation.

Changes

  • Added docs/02-pages/04-api-reference/03-functions/use-search-params.mdx
  • Added docs/02-pages/04-api-reference/03-functions/use-params.mdx

Why

Both useSearchParams and useParams from next/navigation work in the Pages Router, but this was not well documented. The only mention was a brief note in the App Router docs and a migration section in the Pages Router useRouter docs.

What's Documented

For both hooks:

  • Basic usage with the fallback UI pattern for handling null during pre-rendering
  • Return values and behavior differences from App Router
  • Usage with getServerSideProps (where params are immediately available)
  • Examples for sharing components between App Router and Pages Router

For useParams specifically:

  • Comparison with router.query (which includes both dynamic params and query string params)

Related Test

The existing test at test/e2e/app-dir/params-hooks-compat validates that these hooks work in both routers.

@nextjs-bot nextjs-bot added created-by: Turbopack team PRs by the Turbopack team. Documentation Related to Next.js' official documentation. labels Jan 12, 2026
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@timneutkens timneutkens marked this pull request as ready for review January 12, 2026 14:53
const router = useRouter()
const searchParams = useSearchParams()

const createQueryString = useCallback(
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we need useCallback here?

Copy link
Member Author

@timneutkens timneutkens Jan 14, 2026

Choose a reason for hiding this comment

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

Copy link
Contributor

@samselikoff samselikoff left a comment

Choose a reason for hiding this comment

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

Think the useCallback is premature, should we remove it?

Copy link
Member Author

Yeah it doesn't make sense in that context 👍

Copy link
Member Author

Actually it's the same as the current useSearchParams documentation
https://github.com/vercel/next.js/blob/canary/docs/01-app/03-api-reference/04-functions/use-search-params.mdx#L292

@timneutkens timneutkens merged commit 304940e into canary Jan 14, 2026
73 checks passed
@timneutkens timneutkens deleted the docs/pages-router-navigation-hooks branch January 14, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Turbopack team PRs by the Turbopack team. Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants