Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
API reference@auth/neo4j-adapter

@auth/neo4j-adapter

Official Neo4j adapter for Auth.js / NextAuth.js.

Installation

npm install @auth/neo4j-adapter neo4j-driver

Neo4jOptions

This is the interface of the Neo4j adapter options. The Neo4j adapter takes a Neo4j session as its only argument.

Extends

  • Session

Methods

_beginTransaction()

_beginTransaction(
   accessMode, 
   txConfig, 
   apiTelemetryConfig?): TransactionPromise
Parameters
ParameterType
accessModeSessionMode
txConfigTxConfig
apiTelemetryConfig?NonAutoCommitApiTelemetryConfig
Returns

TransactionPromise

Inherited from
Session._beginTransaction

_connectionHolderWithMode()

_connectionHolderWithMode(mode): ConnectionHolder
Parameters
ParameterType
modeSessionMode
Returns

ConnectionHolder

Inherited from
Session._connectionHolderWithMode

_run()

_run<T>(
   query, 
   parameters, 
   customRunner): Result
Type Parameters
Type ParameterDefault type
T extends ResultStreamObserverResultStreamObserver
Parameters
ParameterType
queryQuery
parametersany
customRunnerConnectionConsumer<T>
Returns

Result

Inherited from
Session._run

_runTransaction()

_runTransaction<T>(
   accessMode, 
   transactionConfig, 
transactionWork): Promise<T>
Type Parameters
Type Parameter
T
Parameters
ParameterType
accessModeSessionMode
transactionConfigTxConfig
transactionWorkTransactionWork<T>
Returns

Promise<T>

Inherited from
Session._runTransaction

beginTransaction()

beginTransaction(transactionConfig?): TransactionPromise

Begin a new transaction in this session. A session can have at most one transaction running at a time, if you want to run multiple concurrent transactions, you should use multiple concurrent sessions.

While a transaction is open the session cannot be used to run queries outside the transaction.

Parameters
ParameterTypeDescription
transactionConfig?TransactionConfigConfiguration for the new auto-commit transaction.
Returns

TransactionPromise

New Transaction.

Inherited from
Session.beginTransaction

close()

close(): Promise<void>

Close this session.

Returns

Promise<void>

Inherited from
Session.close

executeRead()

executeRead<T>(transactionWork, transactionConfig?): Promise<T>

Execute given unit of work in a READ transaction.

Transaction will automatically be committed unless the given function throws or returns a rejected promise. Some failures of the given function or the commit itself will be retried with exponential backoff with initial delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config’s maxTransactionRetryTime property in milliseconds.

Type Parameters
Type Parameter
T
Parameters
ParameterTypeDescription
transactionWorkManagedTransactionWork<T>Callback that executes operations against a given Transaction.
transactionConfig?TransactionConfigConfiguration for all transactions started to execute the unit of work.
Returns

Promise<T>

Resolved promise as returned by the given function or rejected promise when given function or commit fails.

Inherited from
Session.executeRead

executeWrite()

executeWrite<T>(transactionWork, transactionConfig?): Promise<T>

Execute given unit of work in a WRITE transaction.

Transaction will automatically be committed unless the given function throws or returns a rejected promise. Some failures of the given function or the commit itself will be retried with exponential backoff with initial delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config’s maxTransactionRetryTime property in milliseconds.

Type Parameters
Type Parameter
T
Parameters
ParameterTypeDescription
transactionWorkManagedTransactionWork<T>Callback that executes operations against a given Transaction.
transactionConfig?TransactionConfigConfiguration for all transactions started to execute the unit of work.
Returns

Promise<T>

Resolved promise as returned by the given function or rejected promise when given function or commit fails.

Inherited from
Session.executeWrite

lastBookmark()

lastBookmark(): string[]

Return the bookmarks received following the last completed Transaction.

Returns

string[]

A reference to a previous transaction.

Deprecated

This method will be removed in version 6.0. Please, use Session#lastBookmarks instead.

See

Session#lastBookmarks

Inherited from
Session.lastBookmark

lastBookmarks()

lastBookmarks(): string[]

Return the bookmarks received following the last completed Transaction.

Returns

string[]

A reference to a previous transaction.

Inherited from
Session.lastBookmarks

readTransaction()

readTransaction<T>(transactionWork, transactionConfig?): Promise<T>

Execute given unit of work in a READ transaction.

Transaction will automatically be committed unless the given function throws or returns a rejected promise. Some failures of the given function or the commit itself will be retried with exponential backoff with initial delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config’s maxTransactionRetryTime property in milliseconds.

Type Parameters
Type Parameter
T
Parameters
ParameterTypeDescription
transactionWorkTransactionWork<T>Callback that executes operations against a given Transaction.
transactionConfig?TransactionConfigConfiguration for all transactions started to execute the unit of work.
Returns

Promise<T>

Resolved promise as returned by the given function or rejected promise when given function or commit fails.

Deprecated

This method will be removed in version 6.0. Please, use Session#executeRead instead.

See

Session#executeRead

Inherited from
Session.readTransaction

run()

run<R>(
   query, 
   parameters?, 
transactionConfig?): Result<R>

Run Cypher query Could be called with a query object i.e.: {text: "MATCH ...", parameters: {param: 1}} or with the query and parameters as separate arguments.

Type Parameters
Type ParameterDefault type
R extends RecordShapeRecordShape
Parameters
ParameterTypeDescription
queryQueryCypher query to execute
parameters?anyMap with parameters to use in query
transactionConfig?TransactionConfigConfiguration for the new auto-commit transaction.
Returns

Result<R>

New Result.

Inherited from
Session.run

writeTransaction()

writeTransaction<T>(transactionWork, transactionConfig?): Promise<T>

Execute given unit of work in a WRITE transaction.

Transaction will automatically be committed unless the given function throws or returns a rejected promise. Some failures of the given function or the commit itself will be retried with exponential backoff with initial delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config’s maxTransactionRetryTime property in milliseconds.

Type Parameters
Type Parameter
T
Parameters
ParameterTypeDescription
transactionWorkTransactionWork<T>Callback that executes operations against a given Transaction.
transactionConfig?TransactionConfigConfiguration for all transactions started to execute the unit of work.
Returns

Promise<T>

Resolved promise as returned by the given function or rejected promise when given function or commit fails.

Deprecated

This method will be removed in version 6.0. Please, use Session#executeWrite instead.

See

Session#executeWrite

Inherited from
Session.writeTransaction

format

const format: {
  from: null | T;
  to: Record<string, unknown>;
};

Type declaration

from()

Takes a Neo4j object and returns a plain old JavaScript object

Type Parameters
Type ParameterDefault type
TRecord<string, unknown>
Parameters
ParameterType
object?Record<string, any>
Returns

null | T

to()

Takes a plain old JavaScript object and turns it into a Neo4j compatible object

Parameters
ParameterType
objectRecord<string, any>
Returns

Record<string, unknown>


Neo4jAdapter()

function Neo4jAdapter(session): Adapter

Parameters

ParameterType
sessionSession

Returns

Adapter

Auth.js © Balázs Orbán and Team - 2025