Development socket
Options
Where the socket listens, how it publishes its URL and how it treats clients.
pglite.socket takes false (the default), true (every default) or an object. It is development only, and independent of server.enabled:
nuxt.config.ts
export default defineNuxtConfig({
pglite: {
socket: {
host: '127.0.0.1',
port: 5433,
env: 'DATABASE_URL',
maxConnections: 10,
idleInTransactionTimeout: 60_000,
},
},
})
| Option | Type | Default | |
|---|---|---|---|
host | string | '127.0.0.1' | Interface to listen on. With 0.0.0.0 or ::, the URL points at the loopback address. |
port | number | a free port | Pin it so that tools outside Nuxt can find the socket. |
path | string | A directory to serve a Unix socket from, instead of host. See below. | |
env | string | false | SocketEnv | 'DATABASE_URL' | What is exported, each variable only while unset: a name for the URL, a map (SocketEnv) of names to strings or to functions of the URL, or false for nothing. |
provider | SocketProvider ('netlify') | Exports a host's database variables in place of DATABASE_URL; env is merged over them. | |
maxConnections | number | unlimited | Clients beyond this many are refused with SQLSTATE 53300 (too_many_connections). |
idleInTransactionTimeout | number | 0 (off) | Milliseconds a client may sit idle inside a transaction or pipeline before it is disconnected with SQLSTATE 25P03, which rolls the transaction back and frees the database for the others. |
devtoolsActions | PGliteSocketAction[] | [] | socket actions, run in the Nuxt process next to the socket, from DevTools or the terminal. Other modules add theirs through the pglite:devtools:actions hook. |
Unix socket
path is a directory, as Postgres clients expect when given a directory as host. The socket file inside it is named .s.PGSQL.<port>, with 5432 unless port is set. A relative path is resolved from the root directory, and a stale socket file left by a previous run is removed first.
nuxt.config.ts
export default defineNuxtConfig({
pglite: {
socket: { path: '.data/socket' },
},
})
The URL then carries the directory as its host parameter:
Terminal
✔ PGlite socket listening at postgres://postgres@localhost:5432/postgres?host=%2Fhome%2Fme%2Fapp%2F.data%2Fsocket (DATABASE_URL)
Terminal
psql -h ./.data/socket -U postgres