> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Postgres

> Mount a Postgres database as a read-only filesystem of schemas, tables, and rows.

`PostgresVFS` connects to Postgres via a DSN and exposes its schemas and tables as a tree.

Setup steps for the DSN and required permissions live at [Postgres Credentials](/home/setup/postgres).

## Node

```bash theme={null}
pnpm add @struktoai/mirage-node pg
```

```ts theme={null}
import { MountMode, PostgresVFS, Workspace } from '@struktoai/mirage-node'

const pg = new PostgresVFS({
  dsn: process.env.PG_DSN!,
  schemas: ['public', 'analytics'],
})

const ws = new Workspace({ '/pg': pg }, { mode: MountMode.READ })
await ws.shell('ls /pg/public/')
```

## Browser

```bash theme={null}
pnpm add @struktoai/mirage-browser
```

For browser apps, point the VFS at a same-origin proxy or use a serverless Postgres driver such as `@neondatabase/serverless`. The browser examples include a Vite plugin that wires the VFS to a server-side `pg` client:

```ts theme={null}
import { MountMode, PostgresVFS, Workspace } from '@struktoai/mirage-browser'

const pg = new PostgresVFS({
  dsn: 'postgres-proxy://app',
})
```

## Config

| Field | Default | Notes |
| - | - | - |
| `dsn` | required | Postgres connection string. Redacted in snapshots. |
| `schemas` | none | Optional list to limit which schemas appear in the tree. |
| `defaultRowLimit` | `1000` | Rows a windowed read returns when it passes an offset but no limit. |
| `maxReadRows` | `10_000` | Hard ceiling per read. A whole read past it is refused; `head -n` / `tail -n` past it print that many rows, then a notice on stderr, and exit 1. |
| `maxReadBytes` | `10 MiB` | Hard ceiling per read. |

## Mount mode

`read` only. Postgres mounts are read-only at the VFS level.

## Snapshot behavior

The DSN is redacted on snapshot. Loading a snapshot back requires a config file that supplies a fresh DSN.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.