Options
export default defineNuxtConfig({
pglite: {
server: {
enabled: true,
config: 'server/pglite.config',
options: { dataDir: '.data/pglite' },
eager: false,
},
},
})
enabled
boolean, default true. Registers usePGlite() and puts PGlite in the server bundle. With false, nothing of PGlite is bundled and #pglite/server resolves to a stub; the development socket still works.
config
string, default 'server/pglite.config'. Path of the config file, relative to the root directory, extension optional. A config file that exists while the server side is disabled and has no socket logs a warning, since nothing uses it.
options
PGlite options, default {}. Build-time defaults the config file can override, limited to what survives serialization into the build: no extensions, fs, loadDataDir, parsers or serializers (those go in the config file).
A relative options.dataDir is resolved from the root directory at build time, and its parent directories are created. Unset, it is .data/pglite.
eager
boolean, default false. Creates the instance when the server starts instead of on the first usePGlite(), so the first request does not pay for it.
pglite.socket, and works with the server side disabled.Runtime overrides
NUXT_PGLITE_DATA_DIR sets the data directory at runtime, winning over both nuxt.config.ts and the config file. A relative path is resolved from the working directory of the server process:
NUXT_PGLITE_DATA_DIR=/var/lib/my-app/pglite node .output/server/index.mjs
Nuxt 5 and Nitro 3
On Nitro 3, server dependencies are bundled. A bundled PGlite would be separated from the WebAssembly and extension files it loads at runtime, so the module keeps it whole: @electric-sql/pglite* and every package your server config file imports (relative imports included) are traced as complete packages.
A package that reaches PGlite some other way, and needs to stay whole for the same reason, goes in Nitro's own list:
export default defineNuxtConfig({
nitro: {
traceDeps: ['my-pglite-extension'],
},
})
On Nitro 2 (Nuxt 4) dependencies stay external and none of this applies.