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.
npm i cyphraimport { createClient } from "./cyphra.gen.js"; const db = createClient({ uri, user, password }); const users = await db.user.findMany({ include: { posts: true },});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.
// 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.
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())
}Your schema is a graph too. FOLLOWS types its edges, so since is typed on the edge.
Typed client
A client that knows your graph.
cyphra generate writes one file, cyphra.gen.ts. Import it and every query is checked against your schema.
- Typed from the schemaFilters,
selectandincluderesults are inferred. Rename a field and the compiler finds every call site. - Nested writes, one transactionCreate and connect related nodes in one call. All of it lands, or none of it.
- Typed relationship propertiesModel an edge with
relationshipand its properties come back typed under$edge.
// 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 edgeDeveloper 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.tsQuickstart
Empty folder to typed graph in three commands.
Install cyphra and @cyphra/cli, write a schema, then run:
- 01
Start Neo4j
Runs Neo4j 5 in Docker on localhost and writes your .env.
npx cyphra dev - 02
Migrate
Turns schema changes into a migration you review and commit.
npx cyphra migrate dev --name init - 03
Generate
Writes cyphra.gen.ts: your typed client, ready to import.
npx cyphra generate
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.
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-backupsCyphra 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
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.
npm i cyphra