Skip to content

Commit 9fcd1e7

Browse files
authored
docs: add most common status codes to redirect() doc (#13301)
1 parent 1c77e28 commit 9fcd1e7

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.changeset/quick-crabs-camp.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sveltejs/kit": patch
3+
---
4+
5+
chore: add most common status codes to `redirect()` JS documentation

packages/kit/src/exports/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ export function isHttpError(e, status) {
8484
/**
8585
* Redirect a request. When called during request handling, SvelteKit will return a redirect response.
8686
* Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.
87+
*
88+
* Most common status codes:
89+
* * `303 See Other`: redirect as a GET request (often used after a form POST request)
90+
* * `307 Temporary Redirect`: redirect will keep the request method
91+
* * `308 Permanent Redirect`: redirect will keep the request method, SEO will be transferred to the new page
92+
*
93+
* [See all redirect status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages)
94+
*
8795
* @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number)} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.
8896
* @param {string | URL} location The location to redirect to.
8997
* @throws {Redirect} This error instructs SvelteKit to redirect to the specified location.

packages/kit/types/index.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,14 @@ declare module '@sveltejs/kit' {
19011901
/**
19021902
* Redirect a request. When called during request handling, SvelteKit will return a redirect response.
19031903
* Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.
1904+
*
1905+
* Most common status codes:
1906+
* * `303 See Other`: redirect as a GET request (often used after a form POST request)
1907+
* * `307 Temporary Redirect`: redirect will keep the request method
1908+
* * `308 Permanent Redirect`: redirect will keep the request method, SEO will be transferred to the new page
1909+
*
1910+
* [See all redirect status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages)
1911+
*
19041912
* @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.
19051913
* @param location The location to redirect to.
19061914
* @throws {Redirect} This error instructs SvelteKit to redirect to the specified location.

0 commit comments

Comments
 (0)