vercel / vercel/next.js

Server action redirect drops #hash in URL

Open
#77,101 3 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Server Actions
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/kachkaev/next.js-server-action-redirect-url-hash-mwe

To Reproduce
  1. Run npm install; npm run dev
  2. Open http://localhost:3000
  3. Press a button to trigger a server action. It should redirect to /example?hello=world#hash
  4. Observe new URL in the browser
Current vs. Expected behavior

Currently, new URL is http://localhost:3000/example?hello=world
but it should be http://localhost:3000/example?hello=world#hash.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.1.0
Relevant Packages:
  next: 15.3.0-canary.6 // Latest available version is detected (15.3.0-canary.6).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Server Actions

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

next dev (local), next start (local)

Additional context

Received x-action-redirect header contains /example?hello=world#hash;push, so the #hash is transmitted to the client.

Image

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal reproduction: run npm install; npm run dev, trigger the server action, and inspect how the x-action-redirect value is consumed. Done means the browser retains #hash and reaches /example?hello=world#hash instead of dropping the fragment.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.