JavaScript client library for web browsers

  • ECMAScript modules (ESM) and CommonJS modules (CJS)
  • Bundled UMD

This guide presumes some familiarity with JavaScript, browser environments, and InfluxDB. If you’re just getting started with InfluxDB, see .

The examples below configure the authentication token in source code for demonstration purposes only. To protect your data, take the following steps:

  1. Avoid sending tokens to public clients such as web browsers and mobile apps. Regard any application secret sent to client devices as public and not confidential.

  2. Use short-lived, read-only tokens whenever possible to prevent unauthorized writes and deletes.

If you use a module bundler like Webpack or Parcel, install . For more information and examples, see .

  1. Configure InfluxDB properties for your script.

  2. Import modules from the latest client library browser distribution. @influxdata/influxdb-client-browser exports bundled ESM and UMD syntaxes.

    ESM

After you’ve imported the client library, you’re ready to write data to InfluxDB.

  1. Clone the repo.

  2. Navigate to the directory:

  3. Update ./env_browser.js with your InfluxDB url, , organization, and

  4. Run the following command to start the application at http://localhost:3001/examples/index.html

    loads the env_browser.js configuration, the client library ESM modules, and the application in your browser.