docs: update usage

This commit is contained in:
Alex Yang
2026-02-07 08:52:08 -08:00
parent dd6dc4601f
commit 91d32ada08

View File

@@ -73,12 +73,13 @@ The `api` object exported from the auth instance contains all the actions that y
"use server" // Waku currently only supports file-level "use server"
import { auth } from "./auth"
import { unstable_getContext as getContext } from "waku/server"
import { unstable_getHeaders as getHeaders } from "waku/server"
export const someAuthenticatedAction = async () => {
"use server"
const headers = getHeaders()
const session = await auth.api.getSession({
headers: new Headers(getContext().req.headers),
headers,
})
};
```
@@ -88,20 +89,21 @@ export const someAuthenticatedAction = async () => {
```tsx
import { auth } from "../auth"
import { unstable_getContext as getContext } from "waku/server"
import { unstable_getHeaders as getHeaders } from "waku/server"
export async function ServerComponent() {
const session = await auth.api.getSession({
headers: new Headers(getContext().req.headers),
})
if(!session) {
return <div>Not authenticated</div>
}
return (
<div>
<h1>Welcome {session.user.name}</h1>
</div>
)
const headers = getHeaders()
const session = await auth.api.getSession({
headers,
})
if(!session) {
return <div>Not authenticated</div>
}
return (
<div>
<h1>Welcome {session.user.name}</h1>
</div>
)
}
```