Skip to Content
v0.2Migrations generated from schema diffs

The typed OGM for Neo4j.

An object-graph mapper, what other stacks call an ORM. Describe your graph in one .cyphra schema. Query its nodes and relationships with a TypeScript client that knows every property.

Get started
npm i cyphra
import { createClient } from "./cyphra.gen.js"; const db = createClient({ uri, user, password }); const users = await db.user.findMany({  include: { posts: true },});
cyphra.gen.ts up to dateTypeScript · 0 problems
neo4j://localhost:7687(:User)-[:AUTHORED]->(:Post)
WORKS_ATWORKS_ATFOLLOWSFOLLOWSAUTHOREDAUTHOREDAUTHOREDTAGGEDTAGGEDTAGGEDacme:Companyalice:Userbob:Usercarol:Userp1:Postp2:Postp3:Postneo4j:Tagtypescript:TagWORKS_ATFOLLOWSAUTHOREDAUTHOREDacme:Companyalice:Userbob:Userp1:Postp2:Post
noderelationshipinclude.posts → [:AUTHORED]

TypeScript and Node.js

Using Neo4j from TypeScript

Neo4j is the database, TypeScript is the language your app is written in: you use them together, not one instead of the other. The official neo4j-driver connects Node.js to Neo4j, but it returns untyped records, so every value is any until you cast it. Cyphra adds the types: it generates a client from your schema, and runs on the same driver. See Cyphra vs neo4j-driver.

users.tstyped
// neo4j-driver: the record knows nothing about your graph
const { records } = await driver.executeQuery(
  "MATCH (u:User {email: $email}) RETURN u",
  { email },
);
records[0].get("u").properties.name; // any

// Cyphra: the same read, typed from schema.cyphra
const db = createClient({ uri, user, password });
const user = await db.user.findUnique({
  where: { email },
  include: { posts: true },
});
user?.name;  // string | null
user?.posts; // Post[]

Schema

One file describes the whole graph.

Nodes, relationships, their direction and their properties live in schema.cyphra. Constraints, indexes, migrations and TypeScript types all come from it.

schema.cyphra
node User {
  id        String  @id @default(cuid())
  email     String  @unique
  name      String?
  posts     Post[]  @out(AUTHORED)
  following User[]  @out(FOLLOWS)
}

node Post {
  id        String  @id @default(uuid())
  title     String
  published Boolean @default(false)
  author    User?   @in(AUTHORED)
}

relationship FOLLOWS {
  since DateTime @default(now())
}
AUTHOREDFOLLOWSsince: DateTime:Userid Stringemail Stringname String?:Postid Stringtitle Stringpublished Boolean

Your schema is a graph too. FOLLOWS types its edges, so since is typed on the edge.

main.tstyped
// One call, one transaction: a user, their post, an edge.
const alice = await db.user.create({
  data: {
    email: "alice@example.com",
    posts: { create: [{ title: "Graphs are everywhere" }] },
    following: { connect: { email: "bob@example.com" } },
  },
  include: { posts: true, following: true },
});

alice.posts;                    // Post[]
alice.following[0].$edge.since; // Date, from the FOLLOWS edge

Developer experience

Built for the inner loop.

Mistakes show up in your editor, schema changes become reviewable code, and a local database is one command away.

Typos fail the build, not production

Every filter is checked against the schema.

await db.user.findMany({
  where: { emial: "alice@example.com" },
});ts(2561) Object literal may only specify known properties, but 'emial' does not exist in type 'WhereInput<…, "User">'. Did you mean to write 'email'?

A local Neo4j in one command

Docker, a data volume and your .env, ready.

$ npx cyphra dev
Started cyphra-dev-blog; waiting for Neo4j…
Wrote .env
✓ Neo4j is ready (browser: http://127.0.0.1:7474).

Migrations you can review

cyphra migrate dev diffs your schema and writes the steps: backfills, guards, constraints. How migrations work

$ npx cyphra migrate dev --name add-roles
✓ Created migrations/20261118174710_add-roles.mjs (2 step(s))
export default defineMigration({
  name: "20261118174710_add-roles",
  async up({ db }) {
    // Backfill User.role with its default on existing nodes.
    await db.execute("MATCH (n:`User`) WHERE n.`role` IS NULL SET n.`role` = $value", {
      value: "member",
    });
    // Create constraint User_handle_unique.
    await db.execute("CREATE CONSTRAINT User_handle_unique IF NOT EXISTS …");
  },
});

Cypher is never hidden

db.$cypher sends every value as a parameter and returns plain JavaScript.

const rows = await db.$cypher<{ name: string; n: number }>`
  MATCH (u:User)-[:AUTHORED]->(p:Post)
  WHERE p.published = ${true}
  RETURN u.name AS name, count(p) AS n
`;

Start from the database you have

cyphra pull introspects a live Neo4j and writes the schema for you.

$ npx cyphra pull
$ npx cyphra generate
✓ Wrote cyphra.gen.ts

Quickstart

Empty folder to typed graph in three commands.

Install cyphra and @cyphra/cli, write a schema, then run:

  1. 01

    Start Neo4j

    Runs Neo4j 5 in Docker on localhost and writes your .env.

    npx cyphra dev
  2. 02

    Migrate

    Turns schema changes into a migration you review and commit.

    npx cyphra migrate dev --name init
  3. 03

    Generate

    Writes cyphra.gen.ts: your typed client, ready to import.

    npx cyphra generate

Read the full getting started guide

Hosting

Run Neo4j yourself, or let us run it.

Cyphra works with any Neo4j 5.6+ database. When you need one, both options below run Neo4j Community on Kubernetes.

Cyphra Operator · open source

On your own Kubernetes.

A Kubernetes operator and Helm chart for Neo4j Community. Declare an instance and get persistent storage, credentials, TLS and scheduled S3 backups.

Declarative
One Neo4jInstance resource: version, memory, storage, exposure.
Credentials
A generated password in a <name>-auth Secret, with the connection URI.
TLS
Bolt and HTTPS from any kubernetes.io/tls Secret, such as one from cert-manager.
Backups
Scheduled and on-demand dumps to any S3-compatible storage, with retention.
blog.yamlkubectl apply
apiVersion: cyphra.dev/v1alpha1
kind: Neo4jInstance
metadata:
  name: blog
spec:
  version: "5.26"
  resources:
    limits: { memory: 2Gi }
  storage: { size: 20Gi }
  tls: { secretName: blog-tls }
  backup:
    schedule: "0 3 * * *"
    s3:
      bucket: my-backups
      credentialsSecretName: s3-backups

Cyphra Cloud · early access

Managed, one instance per database.

A dedicated Neo4j Community instance with its own storage, generated credentials and a TLS endpoint. You get a neo4j+s:// URI; we run the server.

  • Free1 GB memory · 2 GB storage$0
  • Starter2 GB memory · 10 GB storage$29
  • Pro8 GB memory · 50 GB storage$99
  • Team16 GB memory · 100 GB storageCustom
  • TLS endpoint, any Neo4j driver
  • Generated credentials
  • Daily backups on paid plans
  • Storage grows online
.envfrom the dashboard
NEO4J_URI=neo4j+s://<your-database-host>:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=<your-password>

Coming soon to the Vercel Marketplace.

Give your graph a schema.

Install, write a schema, run your first typed query.

Get started
npm i cyphra