mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-26 10:18:34 +02:00
Move to TanStack Start from Next.js (#184)
This commit is contained in:
15
web/app/routes/_layout/_pages/_protected.tsx
Normal file
15
web/app/routes/_layout/_pages/_protected.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router"
|
||||
|
||||
export const Route = createFileRoute("/_layout/_pages/_protected")({
|
||||
beforeLoad: ({ context, location, cause }) => {
|
||||
if (cause !== "stay") {
|
||||
if (!context?.user?.userId) {
|
||||
throw redirect({
|
||||
to: "/sign-in/$",
|
||||
search: { redirect_url: location.pathname },
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
component: () => <Outlet />,
|
||||
})
|
||||
Reference in New Issue
Block a user