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.
| Key | Type | Default | |
|---|---|---|---|
host | string | '127.0.0.1' | Interface to bind. |
port | number | a free port | Port to bind. |
path | string | Directory for a Unix socket; takes precedence over host. Relative to the root directory. | |
env | string | 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. |
provider | SocketProvider | A host's database variables in place of DATABASE_URL ('netlify'); env is merged over them. | |
maxConnections | number | unlimited | Concurrent clients allowed. |
idleInTransactionTimeout | number | 0 | Milliseconds a client may sit idle inside a transaction before it is disconnected; 0 disables it. |
devtoolsActions | PGliteSocketAction[] | [] | 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
| Value | Exports |
|---|---|
'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:
| Key | Type | Default | |
|---|---|---|---|
user | string | 'postgres' | User name put in the URL. Clients are not authenticated. |
database | string | 'postgres' | Database name put in the URL. Every name reaches the same database. |
logger | (...message) => void | silent | Receives unexpected connection errors. |
port defaults to a free port there too. See Through the socket.