nextjs - 💡(How to fix) Fix useSearchParams() doesn't work if the parameter value contains +, the plus character gets replace by a space [6 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#84486Fetched 2026-04-08 02:19:10
View on GitHub
Comments
6
Participants
4
Timeline
20
Reactions
0
Author
Assignees
Timeline (top)
commented ×6mentioned ×4subscribed ×4labeled ×2

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11
Binaries:
  Node: 22.18.0
  npm: N/A
  Yarn: N/A
  pnpm: 10.15.1
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: 14.2.30
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.8.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/fast-brook-nh3xgg

To Reproduce

Using the search example from the docs https://nextjs.org/docs/app/api-reference/functions/use-search-params#dynamic-rendering

console.log of search will not show the plus character but replace it with a space when fetching it through the useSearchParams function and calling the get method.

Current vs. Expected behavior

Current behavior If the search parameter is ?search=123+456 the console log will show 123 456 and not keep the + but replace it with space

Expected behavior would be to keep the + character in the value

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11
Binaries:
  Node: 22.18.0
  npm: N/A
  Yarn: N/A
  pnpm: 10.15.1
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: 14.2.30
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.8.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Route Handlers

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

I have tested this on version 14 latest and version 15 latest and it happens both places, not sure this can be handled in some way or there is a work around, but can't find examples in the docs or online in general

extent analysis

TL;DR

The issue can be worked around by manually decoding the search parameter using decodeURIComponent to preserve the plus character.

Guidance

  • The useSearchParams function is likely decoding the search parameter using a mechanism that replaces plus characters with spaces, which is a standard behavior for URL decoding.
  • To verify this, try logging the search parameter using decodeURIComponent to see if it preserves the plus character.
  • As a workaround, consider using decodeURIComponent to decode the search parameter manually, like this: decodeURIComponent(searchParams.get('search')).
  • Be aware that this workaround may have implications for other characters in the search parameter, so test thoroughly to ensure it meets your requirements.

Example

import { useSearchParams } from 'next/navigation';

function MyComponent() {
  const [searchParams] = useSearchParams();

  const search = decodeURIComponent(searchParams.get('search'));
  console.log(search);
}

Notes

This workaround assumes that the plus character is the only character being replaced incorrectly. If other characters are being replaced, a more complex solution may be needed.

Recommendation

Apply workaround: using decodeURIComponent to manually decode the search parameter is a reasonable solution, as it allows for precise control over how the parameter is decoded.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix useSearchParams() doesn't work if the parameter value contains +, the plus character gets replace by a space [6 comments, 4 participants]