{"id":11968,"library":"rudder-sdk-js","title":"RudderStack JavaScript SDK (Deprecated)","description":"The `rudder-sdk-js` package is the original JavaScript SDK for RudderStack, a customer data platform. It enables tracking of customer event data from websites and sending it to various destinations via the RudderStack platform. The current stable version observed in the npm metadata is `2.52.11`. However, this specific package is explicitly marked as *deprecated* and is no longer actively maintained. Users are strongly recommended to migrate to the newer `@rudderstack/analytics-js` package for continued support, enhanced features, and security updates. This SDK allowed for identifying users, tracking actions, and managing event readiness through a global `rudderanalytics` object. Its primary differentiator was providing a unified API for sending data to multiple analytics and marketing tools, acting as a server-side customer data router.","status":"deprecated","version":"2.52.11","language":"javascript","source_language":"en","source_url":"https://github.com/rudderlabs/rudder-sdk-js","tags":["javascript","analytics","rudder","typescript"],"install":[{"cmd":"npm install rudder-sdk-js","lang":"bash","label":"npm"},{"cmd":"yarn add rudder-sdk-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add rudder-sdk-js","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is deprecated; migration to `@rudderstack/analytics-js` is strongly recommended for ongoing support and features.","package":"@rudderstack/analytics-js","optional":false}],"imports":[{"note":"This deprecated package is typically loaded via a script tag, creating a global `window.rudderanalytics` object. Direct ESM/CJS module imports are not the primary or recommended way to interact with this SDK.","wrong":"import { rudderanalytics } from 'rudder-sdk-js';","symbol":"rudderanalytics","correct":"window.rudderanalytics.load('YOUR_WRITE_KEY', 'YOUR_DATAPLANE_URL');"},{"note":"`track` is a method available on the global `rudderanalytics` object after successful initialization. This pattern is for the deprecated SDK.","wrong":"import { track } from 'rudder-sdk-js';","symbol":"track","correct":"window.rudderanalytics.track('Event Name', { property: 'value' });"},{"note":"This import is for the *recommended migration target*, `@rudderstack/analytics-js`, which replaces `rudder-sdk-js`.","wrong":"import { Analytics } from 'rudder-sdk-js';","symbol":"Analytics (new package)","correct":"import { Analytics } from '@rudderstack/analytics-js';"}],"quickstart":{"code":"<html>\n<head>\n  <title>RudderStack Deprecated SDK Quickstart</title>\n  <script type=\"text/javascript\">\n    !function(){var e=window.rudderanalytics=window.rudderanalytics||[];e.methods=[\"load\",\"page\",\"track\",\"identify\",\"alias\",\"group\",\"ready\",\"reset\",\"getAnonymousId\",\"setAnonymousId\"],e.factory=function(t){return function(){var n=Array.prototype.slice.call(arguments);n.unshift(t);e.push(n);return e}};for(var t=0;t<e.methods.length;t++){var n=e.methods[t];e[n]=e.factory(n)}e.load=function(t,n){var r=document.createElement(\"script\");r.type=\"text/javascript\",r.async=!0,r.src=\"https://cdn.rudderlabs.com/rudder-analytics.min.js\";var a=document.getElementsByTagName(\"script\")[0];a.parentNode.insertBefore(r,a);e._writeKey=t;e._options=n};}();\n\n    // Initialize RudderStack (replace with your actual keys)\n    rudderanalytics.load('YOUR_WRITE_KEY', 'YOUR_DATAPLANE_URL');\n\n    rudderanalytics.ready(function() {\n      console.log('RudderStack SDK is ready!');\n      rudderanalytics.track('Product Viewed', {\n        productId: 'RS-123',\n        productName: 'Example Product',\n        category: 'Electronics'\n      });\n      rudderanalytics.identify('user-123', {\n        email: 'test@example.com',\n        plan: 'premium'\n      });\n    });\n  </script>\n</head>\n<body>\n  <h1>Welcome to the website!</h1>\n  <button onclick=\"rudderanalytics.track('Button Clicked', { buttonName: 'Test' })\">Click Me</button>\n  <p>Check your browser console and network requests for RudderStack events.</p>\n</body>\n</html>","lang":"javascript","description":"Demonstrates how to initialize the deprecated RudderStack JavaScript SDK via a script tag and track a product view event after it's ready, along with user identification."},"warnings":[{"fix":"Migrate your integration to the actively supported `@rudderstack/analytics-js` package following the official migration guide available on RudderStack's documentation site.","message":"This `rudder-sdk-js` package is officially deprecated and is no longer maintained. Continued use is not recommended due to lack of security updates, bug fixes, and new features.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"If your project utilizes RudderStack's service worker capabilities, switch to using the `@rudderstack/analytics-js-service-worker` package explicitly.","message":"The service worker export has been moved from `rudder-sdk-js` to a separate, dedicated package, `@rudderstack/analytics-js-service-worker`. Attempting to use service worker features from `rudder-sdk-js` may result in errors or outdated behavior.","severity":"deprecated","affected_versions":">=2.52.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the SDK script tag is correctly placed in the `<head>` section of your HTML and that all RudderStack API calls are made within the `rudderanalytics.ready()` callback or explicitly after the script has fully loaded.","cause":"The SDK script has not loaded or executed correctly, or `rudderanalytics` is being accessed before it is globally available or before the `rudderanalytics.ready()` callback fires.","error":"ReferenceError: rudderanalytics is not defined"},{"fix":"Migrate your project to use the `@rudderstack/analytics-js` package. This new package offers enhanced features, ongoing maintenance, and critical security updates.","cause":"This message (or similar warnings during installation/build) indicates that you are using the `rudder-sdk-js` package, which has been officially deprecated by RudderStack.","error":"This package is deprecated and no longer maintained."}],"ecosystem":"npm"}