From cab3b515f76aab8a3fe08180dd2e5705aeb26c6a Mon Sep 17 00:00:00 2001 From: SeanCassiere <33615041+SeanCassiere@users.noreply.github.com> Date: Sun, 15 Sep 2024 12:52:02 +1200 Subject: [PATCH] docs(start): correctly import the redirect fn --- docs/framework/react/start/server-functions.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/framework/react/start/server-functions.md b/docs/framework/react/start/server-functions.md index 1fc5de364..461c165ad 100644 --- a/docs/framework/react/start/server-functions.md +++ b/docs/framework/react/start/server-functions.md @@ -343,10 +343,11 @@ Server functions can throw a `redirect` error to redirect the user to a differen - During SSR, redirects are handled by sending a 302 response to the client with the new location - On the client, redirects are handled by the router automatically from within a route lifecycle or a component that uses the `useServerFn` hook. If you call a server function from anywhere else, redirects will not be handled automatically. -To throw a redirect, you can use the `redirect` function exported from the `@tanstack/start` package: +To throw a redirect, you can use the `redirect` function exported from the `@tanstack/react-router` package: ```tsx -import { createServerFn, redirect } from '@tanstack/start' +import { redirect } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/start' export const doStuff = createServerFn('GET', async () => { // Redirect the user to the home page @@ -365,7 +366,8 @@ Redirects can utilize all of the same options as `router.navigate`, `useNavigate Redirects can also set the status code of the response by passing a `status` option: ```tsx -import { createServerFn, redirect } from '@tanstack/start' +import { redirect } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/start' export const doStuff = createServerFn('GET', async () => { // Redirect the user to the home page with a 301 status code @@ -383,7 +385,8 @@ export const doStuff = createServerFn('GET', async () => { You can also set custom headers on a redirect by passing a `headers` option: ```tsx -import { createServerFn, redirect } from '@tanstack/start' +import { redirect } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/start' export const doStuff = createServerFn('GET', async () => { // Redirect the user to the home page with a custom header