Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

_authed.tsx

21 lines595 Bytes

1import { SignIn } from '@clerk/tanstack-react-start'
2import { createFileRoute } from '@tanstack/react-router'
3​
4export const Route = createFileRoute('/_authed')({
5 beforeLoad: ({ context }) => {
6 if (!context.userId) {
7 throw new Error('Not authenticated')
8 }
9 },
10 errorComponent: ({ error }) => {
11 if (error instanceof Error && error.message === 'Not authenticated') {
12 return (
13 <div className="flex items-center justify-center p-12">
14 <SignIn routing="hash" forceRedirectUrl={window.location.href} />
15 </div>
16 )
17 }
18​
19 throw error
20 },
21})