-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed as not planned
Description
Describe the bug
Using sveltekit redirect does not work on client side. Results in JS error:
Uncaught
Object { status: 303, location: "/clients/new" }
location: "/clients/new"
status: 303
<prototype>: Object { … }
[events.js:276:3](http://localhost:5173/node_modules/svelte/src/internal/client/dom/elements/events.js)
handle_event_propagation events.js:276
(Async: EventListener.handleEvent)
event_handle render.js:186
_mount render.js:201
hydrate render.js:123
Svelte4Component legacy-client.js:113
<anonymous> legacy-client.js:52
initialize client.js:480
_hydrate client.js:2663
InterpretGeneratorResume self-hosted:1425
AsyncFunctionNext self-hosted:800
(Async: async)
start client.js:325
AsyncFunctionNext self-hosted:800
(Async: async)
<anonymous> (index):13460
(Async: promise callback)
<anonymous>
Would be nice if I could use redirect over window.location, so that it is consistent throughout codebase. For now, I'll fallback to window.location instead.
Reproduction
<script type="ts">
import { redirect } from '@sveltejs/kit'
function onclick() {
redirect(303, '/clients/new')
}
</script>
<button
{onclick}
type="button"
>
Redirect Me
</button>
Logs
System Info
System:
OS: macOS 15.5
CPU: (12) arm64 Apple M3 Pro
Memory: 92.17 MB / 18.00 GB
Shell: 5.9 - /opt/homebrew/bin/zsh
Binaries:
Node: 23.10.0 - ~/.asdf/installs/nodejs/23.10.0/bin/node
Yarn: 4.9.2 - ~/.asdf/installs/nodejs/23.10.0/bin/yarn
npm: 10.9.2 - ~/.asdf/plugins/nodejs/shims/npm
bun: 1.2.16 - /opt/homebrew/bin/bun
Browsers:
Safari: 18.5
npmPackages:
svelte: ^5.34.1 => 5.34.1
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels