# mixpanel-browser

> The official Mixpanel JavaScript browser client library

Latest version **2.83.0** (published 2026-09-08) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install mixpanel-browser
pnpm add mixpanel-browser
yarn add mixpanel-browser
bun add mixpanel-browser
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 2.83.0 |
| Published | 2026-09-08 |
| First published | 2015-10-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 15.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 943 |
| Maintainers | mixpanel-dev, tdumitrescu, mp_jthong, rahul-mixpanel, ketanmixpanel, sonya-park-mp, msiebert-mixpanel, tyler_mixpanel, jakub.grz, jaredcmixpanel |

## Links

- npm: https://www.npmjs.com/package/mixpanel-browser
- Repository: https://github.com/mixpanel/mixpanel-js
- Issues: https://github.com/mixpanel/mixpanel-js/issues
- npm.io page: https://npm.io/package/mixpanel-browser

## Dependencies (5)

- [json-logic-js](https://npm.io/package/json-logic-js.md) 2.0.5
- [@mixpanel/rrweb](https://npm.io/package/@mixpanel/rrweb.md) 2.0.0-alpha.18.6
- [@types/json-logic-js](https://npm.io/package/@types/json-logic-js.md) 2.0.5
- [@mixpanel/rrweb-utils](https://npm.io/package/@mixpanel/rrweb-utils.md) 2.0.0-alpha.18.6
- [@mixpanel/rrweb-plugin-console-record](https://npm.io/package/@mixpanel/rrweb-plugin-console-record.md) 2.0.0-alpha.18.6

## Recent versions

- 2.83.0 (latest) — 2026-09-08
- 2.56.0-ac-alpha-3 (ac-alpha) — 2024-12-16
- 2.23.0-beta (beta) — 2018-09-11
- 2.82.1 — 2026-08-20
- 2.82.0 — 2026-08-12
- 2.81.0 — 2026-07-09
- 2.80.0 — 2026-05-28
- 2.79.0 — 2026-05-14
- 2.78.0 — 2026-04-08
- 2.77.0 — 2026-03-25
- 2.76.0 — 2026-03-18
- 2.75.0 — 2026-02-25
- 2.74.0 — 2026-01-27
- 2.73.0 — 2025-12-23
- 2.72.0 — 2025-11-14
- … 90 more at https://npm.io/package/mixpanel-browser/versions

## README

# Mixpanel JavaScript Library
![Build Status](https://github.com/mixpanel/mixpanel-js/actions/workflows/tests.yml/badge.svg)
[![](http://img.badgesize.io/https://unpkg.com/mixpanel-browser/dist/mixpanel.min.js?compression=gzip)](https://unpkg.com/mixpanel-browser/dist/mixpanel.min.js)

The Mixpanel JavaScript Library is a set of methods attached to a global `mixpanel` object
intended to be used by websites wishing to send data to Mixpanel projects. A full reference
is available [here](https://developer.mixpanel.com/docs/javascript-full-api-reference).

## Alternative installation via NPM
This library is available as a [package on NPM](https://www.npmjs.com/package/mixpanel-browser) (named `mixpanel-browser` to distinguish it from Mixpanel's server-side Node.js library, available on NPM as `mixpanel`). To install into a project using NPM with a front-end packager such as [Vite](https://vitejs.dev/) or [Webpack](https://webpack.github.io/):

```sh
npm install --save mixpanel-browser
```

You can then import the lib:

```javascript
import mixpanel from 'mixpanel-browser';

mixpanel.init("YOUR_TOKEN", {autocapture: true});
mixpanel.track("An event");
```

NOTE: the default `mixpanel-browser` bundle includes a bundled `mixpanel-recorder` SDK. We provide the following options to exclude `mixpanel-recorder` if you do not intend to use session replay or want to reduce bundle size:

To load the core SDK with no option of session recording:
```javascript
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-core';
```

To load the core SDK and optionally load session recording and targeting bundles asynchronously (via script tag):
```javascript
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-modules';
```

## Use as a browser JavaScript module

If you are leveraging [browser JavaScript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can use [`importmap`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap) to pull in this library.

```html
<script type="importmap">
{
  "imports": {
    "mixpanel-browser": "https://cdn.mxpnl.com/libs/mixpanel-js/dist/mixpanel.module.js"
  }
}
</script>
<script type="module" src="main.js"></script>
```

Then you are free to import `mixpanel-browser` in your javascript modules.

```js
// main.js
import mixpanel from 'mixpanel-browser';

mixpanel.init('YOUR_TOKEN', {autocapture: true, debug: true, persistence: 'localStorage'});
```

## Building bundles for release
- Install development dependencies: `npm install`
- Build: `npm run build-dist`

`npm run build-dist` also writes `dist/mixpanel-browser.cdx.json`, a CycloneDX Software Bill of
Materials (SBOM) covering the production dependency tree, so it ships with the published package.
To regenerate just that file: `npm run sbom`.

## Running tests
- Install development dependencies: `npm install`
- Run unit tests: `npm test`
- Start test server for browser tests: `npm run integration_test`
- Browse to [http://localhost:3001/tests/](http://localhost:3001/tests/) and choose a scenario to run

In the future we plan to automate the last step with a headless browser to streamline development (although
Mixpanel production releases are tested against a large matrix of browsers and operating systems).

## Generating and publishing documentation
- Create bundled source build: `npm run build-dist`
- Generate Markdown: `npm run dox` (result is at `doc/readme.io/javascript-full-api-reference.md`)
- Publish to readme.io via the [rdme](https://www.npmjs.com/package/rdme) util: `RDME_API_KEY=<API_KEY> RDME_DOC_VERSION=<version> npm run dox-publish`

## Thanks
For patches and support: @bohanyang, @dehau, @drubin, @D1plo1d, @feychenie, @mogstad, @pfhayes, @sandorfr, @stefansedich, @gfx, @pkaminski, @austince, @danielbaker, @mkdai, @wolever, @dpraul, @chriszamierowski, @JoaoGomesTW, @@aliyalcinkaya, @chrisdeely, @dylan-asos, @chrisknu

---
_Source: https://npm.io/package/mixpanel-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
