Skip to main content

Getting Started


  1. npm install -D @pgtyped/cli typescript (typescript is a required peer dependency for pgtyped)
  2. npm install @pgtyped/runtime (runtime is the only required runtime dependency for pgtyped)
  3. Create a PgTyped config.json file.
  4. Run npx pgtyped -w -c config.json to start PgTyped in watch mode.


PgTyped requires a config.json file to run, a basic config file looks like this:

"transforms": [
"mode": "sql",
"include": "**/*.sql",
"emitTemplate": "{{dir}}/{{name}}.queries.ts"
"srcDir": "./src/",
"failOnError": false,
"camelCaseColumnNames": false,
"db": {
"host": "db",
"user": "test",
"dbName": "test",
"password": "example"

Refer to the CLI page for more info on the config file, available CLI flags and environment variables.


If you are having trouble configuring PgTyped, you can refer to the example app for a preconfigured example.