Installation
Install neogma and configure your TypeScript project
Installation
Install neogma
npm install neogma
# or
pnpm add neogma
# or
yarn add neogmaNeogma includes TypeBox as a dependency, so you do not need to install it separately. You can import Type, Value, and TSchema directly from neogma.
TypeScript configuration
Neogma v2 uses decorators. You can use either TC39 standard decorators (recommended) or legacy experimental decorators.
TC39 decorators (recommended)
No extra configuration is needed. Make sure your tsconfig.json does not have experimentalDecorators enabled:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"strict": true
// Do NOT set "experimentalDecorators": true
}
}Legacy experimental decorators
If you prefer or need to use legacy experimental decorators (for example, in an existing NestJS project), enable them in your tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}Then import decorators from neogma/legacy instead of neogma:
// TC39 (default)
import { Node, PrimaryKey, Property, Relationship, NodeEntity } from 'neogma';
// Legacy experimental decorators
import {
Node,
PrimaryKey,
Property,
Relationship,
NodeEntity,
} from 'neogma/legacy';Both paths produce the same models and are fully interchangeable at runtime.
Neo4j setup
You need a running Neo4j instance. The easiest way to get started locally is with Docker:
services:
neo4j:
image: neo4j:5-enterprise
ports:
- '7474:7474'
- '7687:7687'
environment:
- NEO4J_AUTH=neo4j/password
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yesdocker compose up -dNode.js version
Neogma requires Node.js 22.13.0 or later.