Skip to content

Configuration

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@becem-gharbi/nuxt-zenstack'],
  zenstack: {
    apiPath: '/api/_zenstack',
    fetchPolicy: 'cache-first',
    realtime: false,
    expose: {},
  }
})

Options

apiPath

  • Type: string
  • Default: '/api/_zenstack'

The base path for the auto-generated server endpoints. For example, with the default value, a User model will be accessible at /api/_zenstack/models/User.

fetchPolicy

  • Type: 'cache-first' | 'cache-and-fetch' | 'fetch-only' | 'cache-only'
  • Default: 'cache-first'

The default data-fetching strategy used by read composables.

PolicyBehavior
cache-firstmeans that the query will first try to fetch the data from the store. If the data is not found in the store, it will fetch the data from the server and update the store.
cache-and-fetchmeans that the query will first try to fetch the data from the cache. It will then fetch the data from the server and update the cache.
fetch-onlymeans that the query will only fetch the data from the server. The data will be stored in the store when the query is resolved.
cache-onlymeans that the query will only fetch the data from the store.

realtime

  • Type: boolean
  • Default: false

Enables realtime updates on data mutation via Server-Sent Events. Must be true for useZenstackRealtime to work.

expose

  • Type: Record<string, Array<'read' | 'create' | 'update' | 'delete' | 'realtime'>>
  • Default: {}

Controls which server endpoints are exposed for each data model. Each key is a model name (as defined in your ZModel schema), and the value is an array of permitted operations.

ts
zenstack: {
  expose: {
    User: ['read', 'create', 'update', 'delete', 'realtime'],
    Post: ['read', 'create'],
  }
}

NOTE

The realtime permission in expose does not enable realtime on its own — you also need to set realtime: true in the module config.