nextjs - 💡(How to fix) Fix Props search params swallows + signs [3 comments, 3 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#85707Fetched 2026-04-08 02:14:17
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
0
Author
Timeline (top)
commented ×3labeled ×2closed ×1issue_type_added ×1

Code Example

import { useRouter, useSearchParams } from 'next/navigation';


const { push } = useRouter();

 push(`/?q=Some+Value`, {
        scroll: true,
 });

---

export default async function Other{props}{
  const searchParams = await props.searchParams;

  console.log(searchParams.q);
 /// "Some Value" The + sign is missing

}

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:43 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 24.0.1
  npm: 11.5.2
  Yarn: N/A
  pnpm: 10.11.1
Relevant Packages:
  next: 15.5.6
  eslint-config-next: 15.5.6
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.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/github/vercel/next.js/tree/canary/examples/reproduction-template

To Reproduce

When serializing a protobuffer to a base64 encoded query string the + sign gets dropped when working with the props.searchParams.

import { useRouter, useSearchParams } from 'next/navigation';


const { push } = useRouter();

 push(`/?q=Some+Value`, {
        scroll: true,
 });
export default async function Other{props}{
  const searchParams = await props.searchParams;

  console.log(searchParams.q);
 /// "Some Value" The + sign is missing

}

Current vs. Expected behavior

The + sign is not replaced by a + sign when accessing the props search params.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:43 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 24.0.1
  npm: 11.5.2
  Yarn: N/A
  pnpm: 10.11.1
Relevant Packages:
  next: 15.5.6
  eslint-config-next: 15.5.6
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Linking and Navigating

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

next dev (local)

Additional context

Please check this MSDN article about preserving + signs. https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams#preserving_plus_signs This happens on local dev.

Maybe related: https://github.com/vercel/next.js/issues/54702

extent analysis

TL;DR

To preserve the + sign in query string parameters, consider using the URLSearchParams API with the decode method that replaces + with spaces, as suggested in the provided MSDN article, but actually use URLSearchParams correctly to handle the + sign.

Guidance

  • Review the MDN article about preserving plus signs to understand how URLSearchParams handles + signs.
  • When creating the query string, ensure that + signs are properly encoded to avoid loss during serialization.
  • Consider using the URLSearchParams constructor and its get method to correctly handle query string parameters, including + signs.
  • Verify the behavior in a controlled environment to ensure the fix works as expected.

Example

const params = new URLSearchParams(props.searchParams);
const q = params.get('q');
console.log(decodeURIComponent(q)); // Should preserve the + sign

Notes

The provided example code and environment information suggest that the issue is related to how Next.js handles query string parameters. However, without further details on the specific requirements and constraints, the suggested fix focuses on properly handling + signs using URLSearchParams.

Recommendation

Apply workaround: The suggested fix involves using URLSearchParams to correctly handle query string parameters, including preserving + signs. This approach should provide a reliable workaround for the issue.

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