Skip to content
Source
Sign inSign up
TanStack/router

fix(solid-router-ssr-query): allow redirect inside server function ssr #5668

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

Showing 19 changed files with 58 additions and 0 deletions (loading 13).

x
0 of 19 viewed, 19 left
e2e/react-start/server-functions/src/routeTree.gen.tsModified
View file
32 additions and 0 deletionse2e/react-start/server-functions/src/routes/redirect-test-ssr/index.tsxAdded
View file
@@ -0,0 +1,32 @@
+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-ssr/target' })
+ },
+)
+​
+export const Route = createFileRoute('/redirect-test-ssr/')({
+ component: RouteComponent,
+ ssr: true,
+})
+​
+function RouteComponent() {
+ const redirectFn = useServerFn($redirectServerFn)
+ const query = useQuery({
+ queryKey: ['redirect-test-ssr'],
+ queryFn: () => redirectFn(),
+ })