Skip to content

Installation

  • Node.js 24 or higher for the CLI, migrations, and native adapters
  • TypeScript 5.0 or higher (strict: true recommended)
  • pnpm, npm, or bun

Start with the package combination that matches where your code runs:

Terminal window
pnpm add @jsorm/core @jsorm/node @jsorm/pg pg

For edge apps, @jsorm/runtime + @jsorm/fetch owns request-time queries, while @jsorm/core (CLI) plus @jsorm/node and a native adapter stays in CI/release jobs for jsorm deploy, migrations, and other CLI work.

After installing @jsorm/core, run the CLI to scaffold config and project helpers:

Terminal window
pnpm exec jsorm init
# or, to run without local install:
pnpm dlx @jsorm/core init
  1. Schema path detection — prompts only if src/schema/ does not yet exist (default src/schema/index.ts)

  2. Schema file generation — creates src/schema/index.ts and an example User model at src/schema/main/user.ts (only if they don’t already exist)

  3. Database / adapter setup — loops to collect one or more database connections (name + dialect). If jsorm.config.ts already exists, existing connection sources are preserved and only missing databases are prompted.

  4. Writes jsorm.config.ts — connection sources and runtime config inline, ready to edit

  5. Generates runtime helpers (db.ts by default, jsormdb.ts fallback if needed) for the Node runtime path

  6. Creates .env with a DATABASE_URL placeholder (if one doesn’t exist)

  7. Creates .migrations/schema.json — empty snapshot for migration generation

  8. Verifies bootstrap + worker readiness before reporting init success

Use --no-migrations to skip migration scaffolding entirely (no .migrations/ directory, no migrations block in config).

After init, your project has a central config file that both runtime code and the CLI can share in Node-capable workflows:

// jsorm.config.ts
import { defineConnectionSource, defineJsormConfig } from '@jsorm/core';
import { pgAdapter } from '@jsorm/pg';
const main = defineConnectionSource({
adapter: pgAdapter({
name: 'main',
connectionString: process.env.DATABASE_URL!,
pool: { min: 2, max: 10 },
}),
});
export default defineJsormConfig({
connectionSources: { main },
defaults: {
connectionSource: 'main',
},
});

Node runtime instances can resolve this file during createJsorm().init(). In edge or fetch-only apps, define the same shape with @jsorm/runtime and pass it explicitly.

PackagePurposePeer dependency
@jsorm/coreNode-capable authoring/runtime package for models, queries, config, and migration primitives
@jsorm/runtimeRuntime-safe package for edge or fetch-only application code
@jsorm/nodeRuntime for Node and Bun (on Bun, uses native Bun APIs, no Rust engine)
@jsorm/fetchHTTP/fetch transport for runtime-safe edge access
@jsorm/pgPostgreSQL native adapterpg
@jsorm/mysqlMySQL native adaptermysql2
@jsorm/sqliteSQLite native adaptersqlite3

Install only the runtime and adapter packages you actually use.

Ensure your tsconfig.json includes:

{
"compilerOptions": {
"strict": true,
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
  1. Install the package set that matches your runtime boundary first, then run pnpm exec jsorm init from a project that has @jsorm/core.
  2. Keep DATABASE_URL and other credentials in .env, never committed to source.
  3. Use strict: true in tsconfig.json for full type inference.
  4. Keep one jsorm.config.ts per deploy owner, and separate edge runtime imports from Node CLI ownership.