docs(tanstack): update code block for API route example and fix syntax spacing

This commit is contained in:
Bereket Engida
2025-04-04 15:57:58 +03:00
parent ba83da0f08
commit bcc17b96a0

View File

@@ -12,8 +12,8 @@ Before you start, make sure you have a Better Auth instance configured. If you h
We need to mount the handler to a TanStack API endpoint.
Create a new file: `/app/routes/api/auth/$.ts`
```ts
import { auth } from '@/lib/auth'
```ts title="routes/api/auth/$.ts"
import { auth } from '@/lib/auth' // import your auth instance
import { createAPIFileRoute } from '@tanstack/react-start/api'
export const APIRoute = createAPIFileRoute('/api/auth/$')({
@@ -24,6 +24,4 @@ export const APIRoute = createAPIFileRoute('/api/auth/$')({
return auth.handler(request)
},
})
```
This will allow you to access use the `getSession` method in all of your routes.
```