diff --git a/docs/content/1.getting-started/2.configuration.md b/docs/content/1.getting-started/2.configuration.md index b52d226..7d4f608 100644 --- a/docs/content/1.getting-started/2.configuration.md +++ b/docs/content/1.getting-started/2.configuration.md @@ -81,7 +81,7 @@ Define your authentication logic in `server/auth.config.ts`, including plugins, Use the `defineServerAuth` helper to ensure type safety and access context. -```ts [server/auth.config.ts] +```ts twoslash [server/auth.config.ts] import { defineServerAuth } from '@onmax/nuxt-better-auth' export default defineServerAuth(() => { @@ -103,7 +103,7 @@ The module automatically injects `secret` and `baseURL`. You don't need to confi The `defineServerAuth` callback receives a context object with useful properties: -```ts [server/auth.config.ts] +```ts twoslash [server/auth.config.ts] import { defineServerAuth } from '@onmax/nuxt-better-auth' import { drizzleAdapter } from 'better-auth/adapters/drizzle' @@ -163,8 +163,9 @@ export default defineNuxtModule({ Access sessions from server handlers: -```ts +```ts twoslash const { user, session } = await getUserSession(event) +// ^? if (!user) throw createError({ statusCode: 401 }) ``` diff --git a/docs/content/1.getting-started/3.client-setup.md b/docs/content/1.getting-started/3.client-setup.md index 12a6789..55dbded 100644 --- a/docs/content/1.getting-started/3.client-setup.md +++ b/docs/content/1.getting-started/3.client-setup.md @@ -12,11 +12,12 @@ Create `app/auth.config.ts` and export a `createAppAuthClient` function. This factory function exists because the module needs to inject the correct `baseURL` at runtime. The module calls this function and provides the URL automatically. :: -```ts [app/auth.config.ts] +```ts twoslash [app/auth.config.ts] import { createAuthClient } from 'better-auth/vue' export function createAppAuthClient(baseURL: string) { return createAuthClient({ baseURL }) + // ^? } ``` @@ -24,7 +25,7 @@ export function createAppAuthClient(baseURL: string) { If you added a plugin in your server config (`server/auth.config.ts`), make sure to add its client equivalent here. -```ts [app/auth.config.ts] +```ts twoslash [app/auth.config.ts] import { createAuthClient } from 'better-auth/vue' import { adminClient } from 'better-auth/client/plugins' diff --git a/docs/content/1.getting-started/4.type-augmentation.md b/docs/content/1.getting-started/4.type-augmentation.md index 9eabbf6..691398a 100644 --- a/docs/content/1.getting-started/4.type-augmentation.md +++ b/docs/content/1.getting-started/4.type-augmentation.md @@ -29,7 +29,7 @@ export default defineServerAuth(() => ({ You can immediately access the `role` property in your Vue components: -```vue +```vue twoslash