Reference

Config files

The shape of server/pglite.config.ts and app/pglite.config.ts.

Both files default-export the result of their define helper. The helpers are identity functions that infer the extensions and mark the config with its side: a server config loaded as the client one, or the reverse, fails at load with a pointer to the right helper.

server/pglite.config.ts

definePGliteServerConfig(config: PGliteConfig<E> & EnvOverrides<PGliteConfig<E>>)

definePGliteServerConfig is auto-imported on the server; it is definePGliteConfig from nuxt-pglite/core under its Nuxt name.

KeyType
PGlite optionsPGliteOptions<E>dataDir, extensions, debug, relaxedDurability, username, database, … (reference).
init(pg) => void | Promise<void>Runs once per created instance, before it is handed out.
dispose(pg) => void | Promise<void>Runs before the instance is closed through its provider.
devtoolsActionsPGliteServerAction<E>[]Server actions.
$development / $production / $testPartial<PGliteConfig<E>>Shallow overrides for that environment; $test wins while testing.

pg is PGliteInstanceFor<PGliteConfig<E>>: a PGlite with the namespaces your extensions add.

app/pglite.config.ts

definePGliteClientConfig(config: PGliteClientConfig<E, C> & EnvOverrides<PGliteClientConfig<E, C>>)

definePGliteClientConfig is auto-imported in the app, and provided as a global in the worker bundle.

KeyType
PGlite worker optionsPGliteWorkerOptionsdataDir, debug, relaxedDurability, id, meta, …
extensionsEPostgres extensions, loaded in the worker.
clientExtensionsCExtensions that add a namespace (live, electricSync), loaded on the main thread and typed on the instance.
init(pg) => void | Promise<void>Runs once in each tab that creates the instance.
dispose(pg) => void | Promise<void>Runs before the instance is closed through its provider.
devtoolsActionsPGliteClientAction<C>[]Client actions.
$development / $production / $testPartial<PGliteClientConfig<E, C>>Shallow overrides for that environment.

pg is PGliteClientInstanceFor<…>: a PGliteWorker with the namespaces your clientExtensions add.

Actions

interface PGliteAction<Ctx> {
  id: string // unique among the actions of the same kind
  label: string
  description?: string
  run(ctx: Ctx): unknown // the result is shown in DevTools, reduced to JSON
}
TypeContext
PGliteServerAction<E>{ pg }, the server instance
PGliteClientAction<C>{ pg }, the app's worker instance
PGliteSocketAction{ socketUrl, env, dataDir?, startSubprocess, terminal, logger }, in pglite.socket.devtoolsActions