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:
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.
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 .
Configure InfluxDB properties for your script.
Import modules from the latest client library browser distribution.
@influxdata/influxdb-client-browser
exports bundled ESM and UMD syntaxes.
After you’ve imported the client library, you’re ready to write data to InfluxDB.
Clone the repo.
Navigate to the directory:
Update
./env_browser.js
with your InfluxDB url, , organization, andRun 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.