Last active
May 29, 2025 09:06
-
-
Save sommeeeer/5bd65f8cb32c2fff361452bf0e75444a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // RedirectAction.tsx | |
| import { redirect } from 'next/navigation'; | |
| export default function RedirectAction() { | |
| return ( | |
| <form | |
| action={async () => { | |
| 'use server'; | |
| redirect(`/posts/2`); | |
| }} | |
| > | |
| <button type="submit">Server Action Redirect to /posts/2</button> | |
| </form> | |
| ); | |
| } | |
| // app/posts/[id]/page.tsx | |
| export default async function Page({ | |
| params, | |
| }: { | |
| params: Promise<{ id: string }>; | |
| }) { | |
| const { id } = await params; | |
| return <div>My Post: {id}</div>; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment