For help with importing or requiring Rollbar into your project with Typescript or a version of ECMAScript (ES5/ES6/ES7/ES8/ES9), please see this document here.
This is the recommendation for the majority of modern web applications as most applications use a bundler and modules have made their way through standards and are available in all modern browsers.
Quick Start
Copy-paste the following code into the <head> of every page you want to monitor. It should be as high as possible, before any other <script> tags.
Be sure to replace POST_CLIENT_ITEM_ACCESS_TOKEN with your project's post_client_item access token, which you can find in the Rollbar.com interface. You can find this by going to your project's Settings > Project Access Tokens.
If you're running Rollbar on an environment besides production, change the environment value to something else (e.g. staging). See more configuration options here.
Test your installation
Navigate your browser to a page that has the above code installed
Type the following code into the console and press enter: window.onerror("TestRollbarError: testing window.onerror", window.location.href)
If you're on Firefox, window.onerror is not accessible from the console, so you'll need to try this in your code instead: setTimeout(function() {notThere();}, 1000);.
This simulates an uncaught error. It should appear in your project's dashboard within a few seconds.
For more information on rollbar.js, please see the docs here.
UMD
rollbar.js is also distributed using UMD, so you can use it with browserify, requirejs, webpack, or anything else that uses AMD or CommonJS modules. See the examples for details.
Updated about 1 year ago
\n```\n\nIf you're running Rollbar on an environment besides production, change the `environment` value to something else (e.g. `staging`). See more configuration options [here](https://docs.rollbar.com/docs/rollbarjs-configuration-reference).\n\n### Test your installation\n\n1. Navigate your browser to a page that has the above code installed\n2. Type the following code into the console and press enter: `window.onerror(\"TestRollbarError: testing window.onerror\", window.location.href)`\n\nIf you're on Firefox, `window.onerror` is not accessible from the console, so you'll need to try this in your code instead: `setTimeout(function() {notThere();}, 1000);`.\n\nThis simulates an uncaught error. It should appear in your project's dashboard within a few seconds.\n\n### [Updating your SDK](https://docs.rollbar.com/docs/javascript#upgrading-from-previous-versions)\n\n> 📘 \n> \n> For more information on rollbar.js, please see the docs [here](https://docs.rollbar.com/v1.0.0/docs/javascript).\n\n \n\n### UMD\n\nrollbar.js is also distributed using UMD, so you can use it with browserify, requirejs, webpack, or anything else that uses AMD or CommonJS modules. See the [examples](https://github.com/rollbar/rollbar.js/tree/master/examples) for details.\n\n ","dehydrated":{"toc":"","body":"
📘
For help with importing or requiring Rollbar into your project with Typescript or a version of ECMAScript (ES5/ES6/ES7/ES8/ES9), please see this document here.
This is the recommendation for the majority of modern web applications as most applications use a bundler and modules have made their way through standards and are available in all modern browsers.
\n
Quick Start
\n
Copy-paste the following code into the <head> of every page you want to monitor. It should be as high as possible, before any other <script> tags.
\n
Be sure to replace POST_CLIENT_ITEM_ACCESS_TOKEN with your project's post_client_item access token, which you can find in the Rollbar.com interface. You can find this by going to your project's Settings > Project Access Tokens.
If you're running Rollbar on an environment besides production, change the environment value to something else (e.g. staging). See more configuration options here.
\n
Test your installation
\n\n
Navigate your browser to a page that has the above code installed
\n
Type the following code into the console and press enter: window.onerror("TestRollbarError: testing window.onerror", window.location.href)
\n\n
If you're on Firefox, window.onerror is not accessible from the console, so you'll need to try this in your code instead: setTimeout(function() {notThere();}, 1000);.
\n
This simulates an uncaught error. It should appear in your project's dashboard within a few seconds.
For more information on rollbar.js, please see the docs here.
\n \n
UMD
\n
rollbar.js is also distributed using UMD, so you can use it with browserify, requirejs, webpack, or anything else that uses AMD or CommonJS modules. See the examples for details.
\n "},"mdx":false,"opts":{"alwaysThrow":false,"compatibilityMode":false,"copyButtons":true,"correctnewlines":false,"markdownOptions":{"fences":true,"commonmark":true,"gfm":true,"ruleSpaces":false,"listItemIndent":"1","spacedTable":true,"paddedTable":true},"normalize":true,"lazyImages":true,"reusableContent":{"tags":{}},"safeMode":false,"settings":{"position":true},"theme":"light","customBlocks":{},"resourceID":"5b3a2848b59ff40003acf831","resourceType":"page","baseUrl":"/","terms":[],"variables":{"user":{},"defaults":[]}},"terms":[],"variables":{"user":{},"defaults":[]}},"doc":{"metadata":{"image":[],"title":"","description":"","keywords":"","robots":"index"},"mdx":{"altBody":"","status":"rdmd"},"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get","examples":{"codes":[]}},"next":{"pages":[],"description":""},"algolia":{"publishPending":false,"recordCount":5,"updatedAt":"2024-04-30T15:46:17.123Z","translationFailure":false},"_id":"5b3a2848b59ff40003acf831","version":{"pdfStatus":"","source":"readme","_id":"5a876b07d24de400828cb2fd","project":"5a874ae082fdd5001282c796","createdAt":"2018-02-16T23:36:39.997Z","releaseDate":"2018-02-16T23:36:39.997Z","categories":["5a876b07d24de400828cb2fe","5a876b08d24de400828cb2ff","5a876bcc82fdd5001282cb7c","5a876dd482fdd5001282cbc9","5a876e38ca7829001221eed7","5a876eec82fdd5001282cbcb","5a8f662968264c001f20c132","5a8f66326b00510012de6354","5a8f665f6b00510012de6356","5a8f668168264c001f20c135","5a8f669228fe2b00125ffcff","5a8f66b628fe2b00125ffd00","5a8f66bd6b00510012de6359","5a8f66d025969d0012bc6066","5a8f693228fe2b00125ffd9c","5a90738f86916d001246342a","5a9073fb86916d00124634cc","5a90743a0a654e0033505444","5a9074400a654e0033505447","5a90825f86916d0012464674","5a9087cb0e4768001effa968","5a90882c3f89a0007db28867","5a9088a786916d00124647d0","5a908b8e0e4768001effaa4c","5a908dde0e4768001effaa7a","5a909eb2670276004812dbdf","5a90a2d986916d0012464cc1","5a90ae27da282100121ced2c","5a96083af8f5d70012898e10","5a981af6b2db650012329915","5a981c2af5fcaa0012144047","5aa6fed212c154001231834e","5aeb60063566c8000349b694","5aecbfbfa4c4a200035958bd","5e04c66822bb70006bea3964","5e04ec186c2c3d005d59a743","5e14f0a9f303bb0018c74ac4","6192be6557fe57000f5aaba8","62dca6181f36f8002e0baccb","62de9e06fd51710021a7e872","62de9e1b6316c304034d006b","62dea06d88d21700a1234a48","6376b422081e400003bac42f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0.0","__v":35,"apiRegistries":[]},"project":"5a874ae082fdd5001282c796","category":{"_id":"5a876b08d24de400828cb2ff","project":"5a874ae082fdd5001282c796","version":"5a876b07d24de400828cb2fd","isAPI":false,"reference":false,"createdAt":"2018-02-16T23:36:40.001Z","from_sync":false,"order":1,"slug":"sdks","title":"Languages and Frameworks","__v":0,"type":"guide","id":"5a876b08d24de400828cb2ff"},"user":"63cda809dc634b004444cd70","parentDoc":"5a909ae10e4768001effac02","updates":["5b58e29c4d81fe0003d77316","6152cda9fad40d0063127486","6234f17ca06046004a95d058","62467b99d4875c02dddd6667","624c382a631fa6003956882a","62598ac54b9d7c008b053a04"],"createdAt":"2018-07-02T13:27:36.987Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"isReference":false,"order":0,"body":"> 📘 \n> \n> For help with importing or requiring Rollbar into your project with Typescript or a version of ECMAScript (ES5/ES6/ES7/ES8/ES9), please see this document [here.](https://docs.rollbar.com/docs/importing-or-requiring-rollbar)\n> \n> This is the recommendation for the majority of modern web applications as most applications use a bundler and modules have made their way through standards and are available in all modern browsers.\n\n## Quick Start\n\nCopy-paste the following code into the `` of every page you want to monitor. It should be as high as possible, before any other `\n```\n\nIf you're running Rollbar on an environment besides production, change the `environment` value to something else (e.g. `staging`). See more configuration options [here](https://docs.rollbar.com/docs/rollbarjs-configuration-reference).\n\n### Test your installation\n\n1. Navigate your browser to a page that has the above code installed\n2. Type the following code into the console and press enter: `window.onerror(\"TestRollbarError: testing window.onerror\", window.location.href)`\n\nIf you're on Firefox, `window.onerror` is not accessible from the console, so you'll need to try this in your code instead: `setTimeout(function() {notThere();}, 1000);`.\n\nThis simulates an uncaught error. It should appear in your project's dashboard within a few seconds.\n\n### [Updating your SDK](https://docs.rollbar.com/docs/javascript#upgrading-from-previous-versions)\n\n> 📘 \n> \n> For more information on rollbar.js, please see the docs [here](https://docs.rollbar.com/v1.0.0/docs/javascript).\n\n \n\n### UMD\n\nrollbar.js is also distributed using UMD, so you can use it with browserify, requirejs, webpack, or anything else that uses AMD or CommonJS modules. See the [examples](https://github.com/rollbar/rollbar.js/tree/master/examples) for details.\n\n ","excerpt":"How to configure Rollbar.js to work in the browser | Support Level: Supported","slug":"browser-js","type":"basic","title":"Browser JS","__v":7,"updatedAt":"2024-04-30T15:46:17.128Z","pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-24T00:17:25.789Z","deprecated":false,"icon":"","revision":13,"lastUpdatedHash":"fdfd10051d1a4d61a9dca7c9f3e6c3cbccdb838a","reusableContent":[],"isApi":false,"tutorials":[],"id":"5b3a2848b59ff40003acf831"},"hideTOC":false,"meta":{"_id":"5b3a2848b59ff40003acf831","description":"How to configure Rollbar.js to work in the browser | Support Level: Supported","hidden":false,"image":[],"keywords":"","metaTitle":"Browser JS","parent":"5a909ae10e4768001effac02","robots":"index","slug":"browser-js","title":"Browser JS","type":"docs"},"slugUrl":"/docs/browser-js","config":{"algoliaIndex":"readme_search_v2","amplitude":{"apiKey":"dc8065a65ef83d6ad23e37aaf014fc84","enabled":true},"asset_url":"https://cdn.readme.io","domain":"readme.io","domainFull":"https://dash.readme.com","encryptedLocalStorageKey":"ekfls-2025-03-27","fullstory":{"enabled":true,"orgId":"FSV9A"},"liveblocks":{"copilotId":"co_11Q0l0JJlkcBhhAYUFh8s"},"metrics":{"billingCronEnabled":"true","dashUrl":"https://m.readme.io","defaultUrl":"https://m.readme.io","exportMaxRetries":12,"wsUrl":"wss://m.readme.io"},"proxyUrl":"https://try.readme.io","readmeRecaptchaSiteKey":"6LesVBYpAAAAAESOCHOyo2kF9SZXPVb54Nwf3i2x","releaseVersion":"5.422.0","sentry":{"dsn":"https://3bbe57a973254129bcb93e47dc0cc46f@o343074.ingest.sentry.io/2052166","enabled":true},"shMigration":{"promoVideo":"","forceWaitlist":false,"migrationPreview":false},"sslBaseDomain":"readmessl.com","sslGenerationService":"ssl.readmessl.com","stripePk":"pk_live_5103PML2qXbDukVh7GDAkQoR4NSuLqy8idd5xtdm9407XdPR6o3bo663C1ruEGhXJjpnb2YCpj8EU1UvQYanuCjtr00t1DRCf2a","superHub":{"newProjectsEnabled":true},"wootric":{"accountToken":"NPS-122b75a4","enabled":true}},"context":{"labs":{},"user":{},"terms":[],"variables":{"user":{},"defaults":[]},"project":{"_id":"5a874ae082fdd5001282c796","appearance":{"nextStepsLabel":"Learn More","hideTableOfContents":false,"showVersion":false,"html_hidelinks":false,"html_footer_meta":"","html_head":"\n\n\n\n\n","html_footer":" \n