mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 20:27:44 +00:00
docs(tanstack): migrate from createAPIFileRoute to createServerFileRoute (TanStack Start) (#2984)
The `createAPIFileRoute` method is no longer available in the latest version of TanStack Start. This commit updates the codebase to use the new `createServerFileRoute` method for handling API routes, ensuring compatibility with the latest library version.
This commit is contained in:
@@ -374,15 +374,15 @@ Better Auth supports any backend framework with standard Request and Response ob
|
||||
<Tab value="tanstack-start">
|
||||
```ts title="src/routes/api/auth/$.ts"
|
||||
import { auth } from '~/lib/server/auth'
|
||||
import { createAPIFileRoute } from '@tanstack/react-start/api'
|
||||
import { createServerFileRoute } from '@tanstack/react-start/server'
|
||||
|
||||
export const APIRoute = createAPIFileRoute('/api/auth/$')({
|
||||
GET: ({ request }) => {
|
||||
return auth.handler(request)
|
||||
},
|
||||
POST: ({ request }) => {
|
||||
return auth.handler(request)
|
||||
},
|
||||
export const ServerRoute = createServerFileRoute('/api/auth/$').methods({
|
||||
GET: ({ request }) => {
|
||||
return auth.handler(request)
|
||||
},
|
||||
POST: ({ request }) => {
|
||||
return auth.handler(request)
|
||||
},
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
|
||||
Reference in New Issue
Block a user