Reference

Socket options

Every key of pglite.socket, and what a test database's socket adds.

pglite.socket takes false (the default), true for every default, or an object. It applies in nuxt dev only, whether or not server.enabled is. The type is exported as SocketOptions from nuxt-pglite. The development socket guide explains each of them in context.

KeyTypeDefault
hoststring'127.0.0.1'Interface to bind.
portnumbera free portPort to bind.
pathstringDirectory for a Unix socket; takes precedence over host. Relative to the root directory.
envstring | false | SocketEnv'DATABASE_URL'Variables exported, each only while unset: a name for the URL, a map of names to strings or functions of the URL, or false for none.
providerSocketProviderA host's database variables in place of DATABASE_URL ('netlify'); env is merged over them.
maxConnectionsnumberunlimitedConcurrent clients allowed.
idleInTransactionTimeoutnumber0Milliseconds a client may sit idle inside a transaction before it is disconnected; 0 disables it.
devtoolsActionsPGliteSocketAction[][]socket actions, run in the Nuxt process next to the socket. Other modules add theirs through the pglite:devtools:actions hook.

SocketEnv

type SocketEnv = Record<string, string | ((url: string) => string)>

Each key is a variable name; a string is exported as is, a function receives the socket's URL. env as a plain string is the shortcut for { [name]: (url) => url }.

SocketProvider

ValueExports
'netlify'NETLIFY_DB_URL (the URL), NETLIFY_DB_DRIVER ('server')

With a provider, DATABASE_URL is not exported unless env adds it. See Provider presets.

Test databases

createTestDatabase({ socket }) and definePGliteGlobalSetup({ socket }) take TestSocketOptions: the keys above but devtoolsActions, plus the socket server's own:

KeyTypeDefault
userstring'postgres'User name put in the URL. Clients are not authenticated.
databasestring'postgres'Database name put in the URL. Every name reaches the same database.
logger(...message) => voidsilentReceives unexpected connection errors.

port defaults to a free port there too. See Through the socket.