Skip to content

Commit 9cd157a

Browse files
committed
docs: add server action redirect example
1 parent f635909 commit 9cd157a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/content/docs/server-action.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ React [Server Actions](https://react.dev/reference/rsc/server-functions) let cli
1212
Define your procedure with `.actionable` for Server Action support.
1313

1414
```ts twoslash
15-
import { onError, os } from '@orpc/server'
15+
import { onError, onSuccess, os } from '@orpc/server'
1616
import { z } from 'zod'
1717
// ---cut---
1818
'use server'
1919

20+
import { redirect } from 'next/navigation'
21+
2022
export const ping = os
2123
.input(z.object({ name: z.string() }))
2224
.handler(async ({ input }) => `Hello, ${input.name}`)
2325
.actionable({
2426
context: async () => ({}), // Optional: provide initial context if needed
2527
interceptors: [
28+
onSuccess(output => redirect(`/some-where`)),
2629
onError(error => console.error(error)),
2730
],
2831
})

0 commit comments

Comments
 (0)