--- title: "Userflow.js Installation: add Userflow to your web app" slug: "userflowjs-installation" description: "Install Userflow.js in your web app with simple steps to enhance user experience without affecting load speed. Secure your users' data effectively!" tags: ["Userflow Installation"] updated: 2026-11-13T16:34:51Z published: 2026-11-13T16:34:51Z canonical: "help.userflow.com/userflowjs-installation" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.userflow.com/llms.txt > Use this file to discover all available pages before exploring further. # Userflow.js Installation: add Userflow to your web app Userflow.js is the JavaScript that shows your flows and other Userflow content to your users. Install it once in your web app, and every flow, checklist, and banner you publish can appear there. Userflow.js loads asynchronously, so it won’t slow down your page load. ## Where can I install Userflow? Userflow.js runs in web apps, including when your users open them in a mobile browser. Userflow also supports: - **Electron apps**, including Windows and Mac desktop apps built with Electron, through [userflow-electron](https://github.com/userflow/userflow-electron). For any other platform, such as a native Windows desktop app, [contact support](mailto:support@userflow.com) and tell us what you’re building on. ## Install Userflow.js with your AI coding agent Let your AI coding agent do the work. Pick the skill that matches where you are: [Install with AI](https://help.userflow.com/docs/install-with-ai) [Verify with AI](https://help.userflow.com/docs/verify-with-ai) [Suggest with AI](https://help.userflow.com/docs/suggest-with-ai) All three are added to your agent the same way. See [Add Userflow coding skills to your agent](https://help.userflow.com/docs/add-userflow-coding-skills-to-your-agent). To install by hand instead, start at [Step 1: Choose installation method](/docs/userflowjs-installation#step-1-choose-installation-method). The installation is simple and only requires 3 quick steps: - [Step 1: Choose installation method](https://help.userflow.com/docs/userflowjs-installation#step-1-choose-installation-method) - [Step 2: Install Userflow.js](https://help.userflow.com/docs/userflowjs-installation#step-2a-npm-installation) - [Step 3: Replace placeholders](https://help.userflow.com/docs/userflowjs-installation#step-3-replace-placeholders) With several optional steps: - [Optional: Add custom attributes](https://help.userflow.com/docs/userflowjs-installation#optional-add-custom-attributes) - [Optional: Enforce identity verification](https://help.userflow.com/docs/userflowjs-installation#optional-enforce-identity-verification) - [Optional: Install Userflow for unauthenticated users](https://help.userflow.com/docs/userflowjs-installation#optional-install-userflow-for-unauthenticated-users) - [Optional: Wait for cookie consent](https://help.userflow.com/docs/userflowjs-installation#optional-wait-for-cookie-consent) ## Step 1: Choose installation method Userflow.js can be installed in one of 2 ways: - Browser apps using module bundlers (such as Webpack or Rollup) - [Go to Step 2A (npm installation)](https://help.userflow.com/docs/userflowjs-installation#step-2a-npm-installation) - Other browser apps and Google Tag Manager - [Go to Step 2B (HTML snippet installation)](https://help.userflow.com/docs/userflowjs-installation#step-2b-html-snippet-installation) We also have specific instructions for special apps/tools: - [Google Tag Manager](https://help.userflow.com/docs/userflowjs-installation-in-google-tag-manager) - [Electron apps via userflow-electron](https://github.com/userflow/userflow-electron) - [GoHighLevel](https://help.userflow.com/docs/userflowjs-installation-in-gohighlevel) - Self-hosted Userflow.js (not recommended). Contact support first, because a self-hosted setup has to be reviewed by Userflow engineering. ## Step 2A: npm installation We recommend installing Userflow.js using the [userflow.js npm package](https://www.npmjs.com/package/userflow.js). First, run this in your Terminal: ```bash npm install userflow.js ``` Import and use the `userflow` object from the `userflow.js` module: ```javascript import userflow from 'userflow.js' userflow.init('USERFLOW_TOKEN') userflow.identify('USER_ID', {  name: 'USER_NAME',  email: 'USER_EMAIL',  signed_up_at: 'USER_SIGNED_UP_AT' }) ``` **Important:** Replace the placeholders in the code (`USERFLOW_TOKEN`, `USER_ID`, `USER_NAME`, `USER_EMAIL`, and `USER_SIGNED_UP_AT`) with real values from your app. See [Step 3: Replace placeholders](https://help.userflow.com/docs/userflowjs-installation#step-3-replace-placeholders). ## Step 2B: HTML snippet installation *Only do this if you did not complete Step 2A.* Copy-paste the following snippet into your HTML document before the ending `</body>` tag: ```javascript ``` **Important:** Replace the placeholders in the code (`USERFLOW_TOKEN`, `USER_ID`, `USER_NAME`, `USER_EMAIL`, and `USER_SIGNED_UP_AT`) with real values from your app. See [Step 3: Replace placeholders](https://help.userflow.com/docs/userflowjs-installation#step-3-replace-placeholders). ## Step 3: Replace placeholders In the Userflow.js code from Step 2A or Step 2B, replace `USERFLOW_TOKEN` with the Userflow.js Token you find under [Settings > Environments](https://help.userflow.com/docs/environments-and-versions). Note that if you have multiple environments (e.g. Production and Staging) that each environment has a unique token. Next, replace `USER_ID` with the currently signed in user’s ID in your database. This is the user's external ID (sometimes shortened to EID): the ID your app uses for the user, which Userflow stores as their user ID. Also replace `USER_NAME`, `USER_EMAIL` and `USER_SIGNED_UP_AT` with the user’s real, dynamic values. `signed_up_at` should be specified in ISO 8601 format. Example: `2019-12-11T12:34:56Z`. **Choose your user ID carefully.** Userflow treats each ID you send to `userflow.identify()` as a separate user. If you later change the ID you send for the same person, Userflow creates a new user. Their history (flow progress, events, attributes) stays on the old user, and there’s no way to merge the two. Before you change the IDs you send, contact support. Userflow’s `user_id_changes` API can move existing users to their new IDs. To move to new IDs safely, see "What happens if you change a user's ID?" in Users and Segments. The properties in `userflow.identify()`‘s second argument are all optional. They’re useful for looking up users in Userflow to e.g. see their flow progress, or to use in the flow content or conditions. If you don’t want to share this with Userflow, feel free to leave out the argument completely. That’s it. Userflow.js is installed. To confirm it’s working, see [Userflow.js installation check](https://help.userflow.com/docs/userflowjs-installation-check). ## Optional: Add custom attributes Userflow.js supports sending custom attributes: Key-value pairs of data such as user role or other preferences. See [Userflow.js Reference](https://docs.userflow.com/docs/userflow-js#attributes) for how to use attributes. ## Optional: Enforce identity verification Identity verification is a Userflow security feature that prevents malicious third parties from impersonating your users. We strongly recommend that you configure and enforce identity verification to safe-guard your users’ information. [See the identity verification guide](https://help.userflow.com/docs/identity-verification) ## Optional: Install Userflow for unauthenticated users Running `userflow.identify()` is a mandatory part of the script. But if you want to show Userflow content on public pages to users who are not yet signed into your application, you can install the script on those pages and replace `userflow.identify()` with `userflow.identifyAnonymous()`. With this function Userflow.js will automatically assign the current user a unique ID. Each anonymous visitor counts toward your MAU total. See [How Userflow Tracks and Bills Monthly Active Users (MAUs)](https://help.userflow.com/docs/how-userflow-tracks-and-bills-monthly-active-users-maus). When a User ID is created for an anonymous end user, it is unique and is also stored in local storage. When `userflow.identifyAnonymous()` is called during subsequent activity by the user, we reuse the already stored anonymous User ID from local storage. The ID stays in local storage until it's cleared. Userflow.js doesn't set cookies for this. [See userflow.identifyAnonymous() docs](https://docs.userflow.com/docs/userflow-js#identifyanonymous) ## Optional: Wait for cookie consent If your app asks users for cookie consent, don't call `userflow.init()` or `userflow.identify()` until they agree, and call `userflow.reset()` if they withdraw it. Userflow.js has no built-in consent setting. For what Userflow stores in the browser and which consent category to use, see [Cookies, browser storage, and consent](https://help.userflow.com/docs/security-privacy-and-compliance#cookies-browser-storage-and-consent). ## Related articles - [Userflow.js installation check](https://help.userflow.com/docs/userflowjs-installation-check) - [Content Security Policy: domains to allow for Userflow.js](https://help.userflow.com/docs/content-security-policy) - [Install Userflow.js with Google Tag Manager](https://help.userflow.com/docs/userflowjs-installation-in-google-tag-manager) - [Identity verification](https://help.userflow.com/docs/identity-verification) - [How Userflow Tracks and Bills Monthly Active Users (MAUs)](https://help.userflow.com/docs/how-userflow-tracks-and-bills-monthly-active-users-maus) ## Related - [Install Userflow.js with Google Tag Manager](/userflowjs-installation-in-google-tag-manager.md) - [Install Userflow.js in GoHighLevel](/userflowjs-installation-in-gohighlevel.md) - [Identity verification: stop others from impersonating your users in Userflow](/identity-verification-1.md)