Guide
Configuration
All module options and environment variables.
nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-postgrest'],
postgrest: {
url: 'http://localhost:3001',
key: '',
tokenKey: 'postgrest_token',
generateTypes: false,
},
})
Options
| Option | Default | Description |
|---|---|---|
url | '' | PostgREST API URL. |
key | '' | Public anon JWT sent when no user token is available. Empty means no Authorization header, so PostgREST uses its db-anon-role. |
tokenKey | 'postgrest_token' | Session field that holds the user's PostgREST JWT. Only used when nuxt-auth-utils is installed (auto-detected) — see Authentication. |
generateTypes | false | Generate the Database type at ~~/shared/types/database.types.ts with the Supabase CLI on nuxt dev / nuxt prepare. |
There's no schema option: clients default to Postgres's public schema, and createPostgrestClient takes an explicit schema for anything else (multi-tenant clients, non-default schemas).
Environment variables
Runtime values can be overridden per environment without rebuilding:
| Variable | Scope | Maps to |
|---|---|---|
NUXT_PUBLIC_POSTGREST_URL | Public | url |
NUXT_PUBLIC_POSTGREST_KEY | Public | key |
NUXT_POSTGREST_SECRET_KEY | Server only | Secret JWT for usePostgrestAdmin() |
NUXT_POSTGREST_DB_URI | Build tooling | Database URL for type generation |
NUXT_POSTGREST_SECRET_KEY usually maps to a role that bypasses RLS. It is never exposed to the client, but keep it out of nuxt.config.ts and version control.