Installation
Packages
- npm
- pnpm
- Yarn
npm install mikro-orm-neo4j
pnpm add mikro-orm-neo4j
yarn add mikro-orm-neo4j
neo4j-driver and @neo4j/cypher-builder are dependencies of the package, so they arrive with it.
What you supply yourself is MikroORM:
- npm
- pnpm
- Yarn
npm install --save-dev @mikro-orm/core @mikro-orm/decorators @mikro-orm/reflection
pnpm add --save-dev @mikro-orm/core @mikro-orm/decorators @mikro-orm/reflection
yarn add --dev @mikro-orm/core @mikro-orm/decorators @mikro-orm/reflection
| Package | Why |
|---|---|
@mikro-orm/core | Peer dependency, 7.x. Pin it exactly if you use stored routines. |
@mikro-orm/decorators | Where MikroORM 7 keeps @Entity, @Property and friends. Not needed with defineEntity. |
@mikro-orm/reflection | TsMorphMetadataProvider, if you would rather not annotate every property type by hand. |
reflect-metadata | Only for the legacy decorator route, imported once at your entry point. |
mikro-orm-neo4j re-exports everything from @mikro-orm/core, plus its own MikroORM,
EntityManager, EntityRepository and defineConfig. Importing MikroORM from the driver is what
selects the Neo4j platform — there is no driver: option to set.
A server to develop against
Neo4j 5 or newer; 5.7 or newer if you plan to use schemas, which need composite uniqueness constraints.
docker run --rm -p 7474:7474 -p 7687:7687 \
-e NEO4J_AUTH=neo4j/password \
neo4j:5.25
Add APOC or GDS with -e NEO4J_PLUGINS='["apoc"]' when you want the
stored routines they ship. Browse the graph at
http://localhost:7474.
For tests, the driver's own suite starts a container per suite with Testcontainers and rolls every write back — see testing.
Connecting
import { defineConfig } from 'mikro-orm-neo4j';
export default defineConfig({
clientUrl: 'bolt://localhost:7687',
user: 'neo4j',
password: 'password',
dbName: 'neo4j',
entities: ['./dist/entities'],
entitiesTs: ['./src/entities'],
});
| Option | Meaning |
|---|---|
clientUrl | Bolt URL. bolt://, bolt+s://, neo4j:// (routing) and neo4j+s:// all work. |
user, password | Basic auth. |
dbName | The Neo4j database. neo4j is the default one on a fresh server. |
ensureDatabase | Set false when the database already exists and the user may not create one (Community only has neo4j). |
replicas | Read replicas — see read replicas. |
driverOptions | Passed to neo4j-driver, e.g. { fetchSize: 500 }, connection pool sizes, custom trust settings. |
debug | ['query', 'query-params'] and friends — see observability. |
Node.js
Node 22 or newer. The driver reads globSync from node:fs, which older runtimes do not
export; on Node 20 the failure is a SyntaxError at import time rather than something informative.
See troubleshooting.
Next
- Quick start — two entities, a write and a read.
- TypeScript setup — how the graph-specific options are typed.