-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: re-export
redirectDocument
from RR (#7040)
- Loading branch information
1 parent
4ddf16f
commit dc76620
Showing
13 changed files
with
91 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@remix-run/react": minor | ||
"@remix-run/server-runtime": minor | ||
--- | ||
|
||
[REMOVE] Update to experimental react router version with Remix back compat code removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@remix-run/cloudflare": minor | ||
"@remix-run/deno": minor | ||
"@remix-run/node": minor | ||
"@remix-run/server-runtime": minor | ||
--- | ||
|
||
Re-export new `redirectDocument` method from React Router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: redirectDocument | ||
toc: false | ||
--- | ||
|
||
# `redirectDocument` | ||
|
||
This is a small wrapper around [`redirect`][redirect] that will trigger a document-level redirect to the new location instead of a client-side navigation. | ||
|
||
This is most useful when you have a Remix app living next to a non-Remix app on the same domain and need to redirect from the Remix app to the non-Remix app: | ||
|
||
```tsx lines=[1,7] | ||
import { redirect } from "@remix-run/node"; // or cloudflare/deno | ||
|
||
export const action = async () => { | ||
const userSession = await getUserSessionOrWhatever(); | ||
|
||
if (!userSession) { | ||
return redirect("/login"); | ||
} | ||
|
||
return json({ ok: true }); | ||
}; | ||
``` | ||
|
||
Just like [`redirect`][redirect], it accepts a status code or a `ResponseInit` as the second parameter: | ||
|
||
``` | ||
redirectDocument(path, 301); | ||
redirectDocument(path, 303); | ||
``` | ||
|
||
```ts | ||
redirectDocument(path, { | ||
headers: { | ||
"Set-Cookie": await commitSession(session), | ||
}, | ||
}); | ||
``` | ||
|
||
[redirect]: ./redirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters