New Survey: Leveraging real-time data delivers higher revenue growth and increased developer productivity. Learn more.

Toggle Menu
TypeScript Support in the DataStax Node.js Drivers

I'm happy to announce built-in TypeScript support in our DataStax Node.js drivers for Apache Cassandra and DataStax Enterprise Node.js Driver.

TypeScript declarations of the driver are now contained in the same package and repository. These declarations will be maintained and kept in sync along with the JavaScript API. 

Additionally, you can now use DSE-specific types like geo, auth and graph types from TypeScript.

Getting started

To get started with the Node.js driver for Apache Cassandra in a TypeScript project, install the driver package:

npm install cassandra-driver

... and you are all set to start coding in TypeScript!

For example, create a simple script to connect and retrieve a single row:

import { Client } from "cassandra-driver";

async function run() {
  const client = new Client({
    contactPoints: [''],
    localDataCenter: 'datacenter1'

  await client.connect();

  const rs = await client.execute('SELECT * FROM system.local');
  const row = rs.first();
  console.log(`Connected to cluster: ${row['cluster_name']}`);

  await client.shutdown();


Compile and run it:

tsc my-file.ts && node my-file.js

You can continue reading here on how to get started with the Node.js drivers.

We would like to thank Michał Kamiński, Christian D and the rest of the community for an excellent job maintaining the driver definitions at DefinitelyTyped project, enabling TypeScript developers to use Apache Cassandra and DSE.

Wrapping up
We hope you enjoy using the driver from TypeScript projects!

If you are updating from community definitions, feel free to remove the @types dependency.

You can get the latest versions of the driver on the npm registry:

Authored by

Sign up for our Developer Newsletter

Get the latest articles on all things data delivered straight to your inbox.

Open-Source, Scale-Out, Cloud-Native NoSQL Database

Astra DB is scale-out NoSQL built on Apache Cassandra™. Handle any workload with zero downtime and zero lock-in at global scale.

Open-Source, Scale-Out, Cloud-Native NoSQL Database