Reference

Exports

What each entry and alias exports.

Auto-imports

ContextNamesRegistered when
Server (Nitro)usePGlite, definePGliteServerConfigserver.enabled
App (Vue)usePGlite, useLiveQuery, useLiveIncrementalQuery, definePGliteClientConfigclient.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.
TypesPGliteConfig, 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.
ProtocolErrorThe error raised for malformed client messages.
TypesPGliteSocketServer, 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.
MigrationErrorA failed migration, with its migration name and the database error as cause.
MigrationDriftErrorApplied migrations edited or removed since, in details.
TypesApplyMigrationsOptions, 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.
TypesTestDatabase, 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.
TypesPGliteGlobalSetupOptions

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:

AliasExportsWhen the side is disabled
#pglite/serverusePGlite, pglite, definePGliteServerConfig; types PGliteConfig, PGliteInstanceFor, PGliteServerActiona stub: usePGlite() rejects with a pointer
#pglite/clientusePGlite, pglite, useLiveQuery, useLiveIncrementalQuery, definePGliteClientConfig; types PGliteClientConfig, PGliteClientInstanceFor, PGliteClientActiona stub: functions fail with a pointer
#pglite/coreas nuxt-pglite/core
#pglite/socketas nuxt-pglite/socket
#pglite/migrationsas nuxt-pglite/migrations

The testing entries have no alias: they run in the test runner, outside the app.