Neo4j Bolt Connection (Internal)

5.28.3 · active · verified Wed Apr 22

The `neo4j-driver-bolt-connection` package provides the low-level implementation for establishing and managing connections to Neo4j databases using the binary Bolt Protocol. It is an internal dependency foundational to the official `neo4j-driver` and `neo4j-driver-lite` packages for JavaScript and TypeScript. Crucially, this package is explicitly *not* intended for direct consumption by end-users, serving as an abstraction layer for Bolt protocol specifics. The current stable version is 5.28.3, with version 6.0.x introducing new features like support for Neo4j's Vector type. Release cadence for the main `neo4j-driver` and its internal components, including this one, has evolved; post-6.0, minor releases occur as warranted by significant features or improvements, moving away from a monthly cadence to reduce user update overhead. Key differentiators include its role in abstracting complex network communication and Bolt handshake protocols, enabling the higher-level drivers to offer robust API usability, transaction management, and connection pooling capabilities transparently. While it handles the core communication, developers should always use the comprehensive `neo4j-driver` for a stable and supported experience.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to connect to a Neo4j database using the official `neo4j-driver` package, which internally relies on `neo4j-driver-bolt-connection`. It shows a basic query execution and proper resource management, emphasizing that direct usage of this internal package is discouraged.

import neo4j from 'neo4j-driver';

// IMPORTANT: neo4j-driver-bolt-connection is an internal package.
// Always use the official 'neo4j-driver' for your applications.

const uri = process.env.NEO4J_URI ?? 'bolt://localhost:7687';
const user = process.env.NEO4J_USERNAME ?? 'neo4j';
const password = process.env.NEO4J_PASSWORD ?? 'password';

const driver = neo4j.driver(uri, neo4j.auth.basic(user, password));

async function queryNeo4j() {
  const session = driver.session();
  try {
    const result = await session.run(
      'CREATE (a:Greeting {message: $message}) RETURN a.message AS message',
      { message: 'Hello, Neo4j!' }
    );
    const singleRecord = result.records[0];
    const message = singleRecord.get('message');
    console.log(`Successfully created a node with message: ${message}`);
  } catch (error) {
    console.error('Error connecting to Neo4j or running query:', error);
  } finally {
    await session.close();
    console.log('Session closed.');
  }
}

queryNeo4j()
  .then(() => driver.close())
  .catch(error => {
    console.error('Driver encountered an error:', error);
    driver.close();
  });

view raw JSON →