TypeScript SDK
Install the native SDK for Node.js, Bun, Deno, or Electron and run your first query.
Use @oliphaunt/ts to run native PostgreSQL in a desktop JavaScript application. For a browser app, use WASIX TypeScript; for a mobile app, use React Native.
Install
The package supports Node.js 22.13 through 24.x. Bun and Deno use their native runtime adapters.
npm install @oliphaunt/ts@0.3.0bun add @oliphaunt/ts@0.3.0Import the npm package with import { Oliphaunt } from 'npm:@oliphaunt/ts@0.3.0';. Enable local npm dependencies so Deno can load the native module:
{ "nodeModulesDir": "auto" }Allow native libraries, database files, environment variables, and the initdb process used to create a database:
deno run --allow-ffi --allow-env --allow-read --allow-write --allow-run main.tsThe package supplies native runtime assets for supported desktop targets. Keep native files available when bundling your application.
Run your first query
Save this example as main.mjs and run node main.mjs or bun main.mjs. For Deno, save it as main.ts and use the npm import and permissions above. It prints 42 and closes the database.
import { Oliphaunt } from '@oliphaunt/ts';
const db = await Oliphaunt.open();
try {
const result = await db.query('SELECT $1::int4 AS answer', [42]);
console.log(result.rows[0]?.answer); // 42
} finally {
await db.close();
}An open handle owns one PostgreSQL session. Queries return promises and execute in order on that session.
Keep data between runs
Use this storage configuration instead of the disposable example above. Direct mode stays bound to its first root for the lifetime of the process; closing does not let the same process switch roots.
Choose a persistent directory instead of the default temporary storage:
const db = await Oliphaunt.open({
storage: { kind: 'directory', path: './app-data/main.oliphaunt' },
});Reopen the same path to use the data again. Keep the handle in application state and close it when the application finishes using it.
Next steps
Query, transact, and back up data, or look up methods and configuration in the API reference.