Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/start/framework/react/guide/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ import { createServerFn } from '@tanstack/react-start'

const db = createMyDatabaseClient()

export const getUser = createServerFn(async ({ ctx }) => {
const user = await db.getUser(ctx.userId)
export const getUser = createServerFn().handler(async ({ context }) => {
const user = await db.getUser(context.userId)
return user
})

export const createUser = createServerFn(async ({ ctx, input }) => {
const user = await db.createUser(input)
return user
})
export const createUser = createServerFn({ method: 'POST' }).handler(
async ({ data }) => {
const user = await db.createUser(data)
return user
},
)
```

This is obviously contrived, but it demonstrates that you can use literally any database provider with TanStack Start as long as you can call into it from a server function or server route.
Expand Down
Loading