Exports
Auto-imports
| Context | Names | Registered when |
|---|---|---|
| Server (Nitro) | usePGlite, definePGliteServerConfig | server.enabled |
| App (Vue) | usePGlite, useLiveQuery, useLiveIncrementalQuery, definePGliteClientConfig | client.enabled |
nuxt-pglite
The module itself (default export) and its types:
- Options:
ModuleOptions,ResolvedModuleOptions,ServerOptions,ClientOptions,SocketOptions,SocketEnv,SocketProvider,SerializablePGliteOptions,SerializablePGliteWorkerOptions - Actions:
PGliteAction,PGliteActionInfo,PGliteActionSide,PGliteServerAction,PGliteServerActionContext,PGliteClientAction,PGliteClientActionContext,PGliteSocketAction,PGliteSocketActionContext - Augmentations:
ModuleHooks,ModuleRuntimeConfig
nuxt-pglite/core
Framework-agnostic; imports @electric-sql/pglite only when an instance is created.
| Export | |
|---|---|
definePGliteConfig(config) | The config helper, definePGliteServerConfig under its plain name. |
createPGliteProvider(config, options?) / createPGliteProvider({ create, init?, dispose?, initScope? }) | A lazy single-instance provider. |
resolveEnvConfig(config, { dev, test }) | Applies and drops the $development / $production / $test keys. |
assertConfigKind(config, kind, file) | Throws when a config made by one side's helper is loaded as the other's. |
| Types | PGliteConfig, PGliteInstanceFor, PGliteProvider, PGliteProviderOptions, Closable, InitScope, EnvOverrides, ConfigKind, PGliteAction, PGliteActionInfo, PGliteActionSide, PGliteServerAction, PGliteServerActionContext |
nuxt-pglite/socket
Depends on @electric-sql/pglite and Node built-ins only.
| Export | |
|---|---|
createPGliteSocketServer(db, options?) | A Postgres wire-protocol server in front of db. |
ProtocolError | The error raised for malformed client messages. |
| Types | PGliteSocketServer, PGliteSocketServerOptions |
nuxt-pglite/migrations
Depends on Node built-ins only.
| Export | |
|---|---|
applyMigrations(db, dir, options?) | Applies the pending migrations in dir, each in a transaction with its tracking row; resolves with the names applied. |
readMigrations(dir) | The migrations in dir, in the order they apply. |
fromPool(pool) | Adapts a pg pool to what applyMigrations needs. |
MigrationError | A failed migration, with its migration name and the database error as cause. |
MigrationDriftError | Applied migrations edited or removed since, in details. |
| Types | ApplyMigrationsOptions, MigrationLogger, MigrationDrift, MigrationExecutor, PoolLike, PoolClientLike, MigrationFile |
nuxt-pglite/testing
Depends on @electric-sql/pglite, jiti (to load config files) and Node built-ins.
| Export | |
|---|---|
createTestDatabase(options?) | A test database built from the app's server config, init included: in memory, forkable, optionally served over the socket. |
loadPGliteConfig(path, { alias }?) | Loads a server config file as the module does, relative to process.cwd(), with $test applied. |
| Types | TestDatabase, TestDatabaseOptions, TestSocketOptions, LoadPGliteConfigOptions |
TestDatabase is { pg, url?, env, fork(options?), close() }; TestSocketOptions is the module's SocketOptions plus the socket server's user, database and logger.
nuxt-pglite/testing/vitest
Loads nothing of vitest at runtime: its types only.
| Export | |
|---|---|
definePGliteGlobalSetup(options?) | A vitest globalSetup module: one database for the run, served over the socket, its variables exported before the workers start. |
| Types | PGliteGlobalSetupOptions |
It augments vitest's ProvidedContext with pglite: { url: string, env: Record<string, string> }, read with inject('pglite').
Aliases
Inside a Nuxt app, each entry is also reachable through an alias:
| Alias | Exports | When the side is disabled |
|---|---|---|
#pglite/server | usePGlite, pglite, definePGliteServerConfig; types PGliteConfig, PGliteInstanceFor, PGliteServerAction | a stub: usePGlite() rejects with a pointer |
#pglite/client | usePGlite, pglite, useLiveQuery, useLiveIncrementalQuery, definePGliteClientConfig; types PGliteClientConfig, PGliteClientInstanceFor, PGliteClientAction | a stub: functions fail with a pointer |
#pglite/core | as nuxt-pglite/core | |
#pglite/socket | as nuxt-pglite/socket | |
#pglite/migrations | as nuxt-pglite/migrations |
The testing entries have no alias: they run in the test runner, outside the app.