Skip to content
Source
Sign inSign up
TanStack/router

fix(solid-start): redirect from server function #5637

Mergedbirkskyum(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/5637/headmerged by birkskyum(GitHub profile, opens in a new tab)

Showing 8 changed files with 52 additions and 0 deletions (loading 3).

x
0 of 8 viewed, 8 left
e2e/react-start/server-functions/src/routeTree.gen.tsModified
View file
29 additions and 0 deletionse2e/react-start/server-functions/src/routes/redirect-test/index.tsxAdded
View file
@@ -0,0 +1,29 @@
+import { useQuery } from '@tanstack/react-query'
+import { createFileRoute, redirect } from '@tanstack/react-router'
+import { createServerFn, useServerFn } from '@tanstack/react-start'
+import { Suspense } from 'react'
+​
+const $redirectServerFn = createServerFn({ method: 'GET' }).handler(async () => {
+ throw redirect({ to: '/redirect-test/target' })
+})
+​
+export const Route = createFileRoute('/redirect-test/')({
+ component: RouteComponent,
+})
+​
+function RouteComponent() {
+ const redirectFn = useServerFn($redirectServerFn)
+ const query = useQuery({
+ queryKey: ['redirect-test'],
+ queryFn: () => redirectFn(),
+ })
+​
+ return (
+ <div>