---
title: Install the InfluxDB v2 JavaScript client library
description: Install the Node.js JavaScript client library to write data to InfluxDB Cloud Serverless.
url: https://docs.influxdata.com/influxdb3/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/install/
estimated_tokens: 982
product: InfluxDB 3 Cloud
version: cloud
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb3/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/install/
date: '2025-04-09T17:03:44-05:00'
lastmod: '2025-04-09T17:03:44-05:00'
---

### Use InfluxDB 3 clients

The `/api/v2/query` API endpoint and associated tooling, such as InfluxDB v2 client libraries and the `influx` CLI, **can’t** query an InfluxDB Cloud Serverless cluster.

[InfluxDB 3 client libraries](/influxdb3/cloud-serverless/client-libraries/v3/) are available that integrate with your code to write and query data stored in InfluxDB Cloud Serverless.

InfluxDB 3 supports many different tools for [**writing**](/influxdb3/cloud-serverless/write-data/) and [**querying**](/influxdb3/cloud-serverless/query-data/) data.[**Compare tools you can use**](/influxdb3/cloud-serverless/get-started/#tools-to-use) to interact with InfluxDB Cloud Serverless.

Install the Node.js JavaScript client library to write data to InfluxDB InfluxDB Cloud Serverless.

## Install Node.js

1. Install [Node.js](https://nodejs.org/en/download/package-manager/).

2. Ensure that InfluxDB is running and you can connect to it.
   For information about what URL to use to connect to InfluxDB Cloud Serverless, see [InfluxDB URLs](/influxdb3/cloud-serverless/reference/urls/).

3. In your terminal, create a directory for your Node.js project and change to it.

   ```
   mkdir influx-node-app && cd influx-node-app
   ```

4. Enter the following command to generate an npm package for your project.

   * `npm`: the package manager included with Node.js
   * `-y`: uses defaults for the package and bypasses prompts

   ```
   npm init -y
   ```

## Install TypeScript

Many of the client library examples use [TypeScript](https://www.typescriptlang.org/).
Follow these steps to initialize the TypeScript project:

1. Install TypeScript and type definitions for Node.js.

   ```
   npm i -g typescript && npm i --save-dev @types/node
   ```

2. Enter the following command to create a TypeScript configuration
   (`tsconfig.json`) with default values:

   ```
   tsc --init
   ```

3. Run the TypeScript compiler.
   To recompile your code automatically as you make changes, pass the `--watch, -w` flag to the compiler.

   ```
   tsc --watch
   ```

## Install dependencies

Use the `@influxdata/influxdb-client` JavaScript client library to write data in InfluxDB Cloud Serverless.

Open a new terminal window and install the `@influxdata/influxdb-client` package for querying and writing data:

```sh
npm i --save @influxdata/influxdb-client
```

The `@influxdata/influxdb-client-apis` client library package won’t work with InfluxDB Cloud Serverless.
It only works with InfluxDB v2 management APIs.

## Configure credentials

The client examples include an [`env`](https://github.com/influxdata/influxdb-client-js/blob/master/examples/env.js) module for accessing your InfluxDB properties from environment variables or from `env.js`.
The examples use these properties to interact with the InfluxDB API.

Set environment variables or update `env.js` with your InfluxDB [bucket](/influxdb3/cloud-serverless/organizations/buckets/), [organization](/influxdb3/cloud-serverless/organizations/), [token](/influxdb3/cloud-serverless/security/tokens/), and [URL](/influxdb3/cloud-serverless/reference/urls/).

```sh
export INFLUX_URL=https://cloud2.influxdata.com
export INFLUX_TOKEN=API_TOKEN
export INFLUX_ORG=ORG_ID
export INFLUX_BUCKET=BUCKET_NAME
```

Replace the following:

* *`API_TOKEN`*: InfluxDB [API token](/influxdb3/cloud-serverless/get-started/setup/#create-an-all-access-api-token) with *write* permission to the bucket.
* *`ORG_ID`*: InfluxDB [organization ID](/influxdb3/cloud-serverless/admin/organizations/view-orgs/)
* *`BUCKET_NAME`*: the name of the InfluxDB Cloud Serverless bucket to write to

## Next steps

Once you’ve installed the client library and configured credentials, you’re ready to [write data](/influxdb3/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/write/).

[Write data](/influxdb3/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/write/)
