{"id":20189,"library":"lightstreamer-client-web","title":"Lightstreamer Client Web SDK","description":"Lightstreamer Client Web SDK (v9.2.3, stable) enables real-time bidirectional communication with a Lightstreamer server from web browsers. It supports WebSocket fallback options and delivers streaming data updates with low latency. Key differentiators: multiple module formats (UMD, CommonJS, ES Module) for varying bundler compatibility; includes core, full, and MPN builds; provides TypeScript definitions. Maintained by Lightstreamer with frequent releases. Ideal for financial tickers, live dashboards, and collaborative applications.","status":"active","version":"9.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/Lightstreamer/Lightstreamer-lib-client-haxe","tags":["javascript","lightstreamer","push","realtime","real-time","websocket","typescript"],"install":[{"cmd":"npm install lightstreamer-client-web","lang":"bash","label":"npm"},{"cmd":"yarn add lightstreamer-client-web","lang":"bash","label":"yarn"},{"cmd":"pnpm add lightstreamer-client-web","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import for modern bundlers; requires using the ES module build.","wrong":"const LightstreamerClient = require('lightstreamer-client-web');","symbol":"LightstreamerClient","correct":"import { LightstreamerClient } from 'lightstreamer-client-web';"},{"note":"Subscription is a named export, not default.","wrong":"import Subscription from 'lightstreamer-client-web';","symbol":"Subscription","correct":"import { Subscription } from 'lightstreamer-client-web';"},{"note":"Import from the package root; bundlers resolve the correct file.","wrong":"import { ConsoleLogger } from 'lightstreamer-client-web/lightstreamer.esm.js';","symbol":"ConsoleLogger","correct":"import { ConsoleLogger } from 'lightstreamer-client-web';"}],"quickstart":{"code":"import { LightstreamerClient, Subscription } from 'lightstreamer-client-web';\nimport { ConsoleLogger } from 'lightstreamer-client-web';\n\nconst client = new LightstreamerClient('http://push.lightstreamer.com', 'DEMO');\nclient.addListener({\n  onListenEnd: () => console.log('Disconnected'),\n  onServerError: (errorCode, errorMessage) => console.error(errorCode, errorMessage),\n  onStatusChange: (newStatus) => console.log('Status:', newStatus)\n});\n\nconst sub = new Subscription('MERGE', ['item1','item2','item3'], ['stock_name','last_price']);\nsub.setDataAdapter('QUOTE_ADAPTER');\nsub.setRequestedSnapshot('yes');\nsub.addListener({\n  onItemUpdate: (obj) => {\n    console.log(obj.getValue('stock_name') + ': ' + obj.getValue('last_price'));\n  },\n  onSubscriptionError: (code, msg) => console.error('Subscription error', code, msg)\n});\n\nclient.connect();\nclient.subscribe(sub);","lang":"typescript","description":"Connects to Lightstreamer demo server, subscribes to three items with MERGE mode, and logs stock updates to console."},"warnings":[{"fix":"Add data-lightstreamer-ns='Ls' to the script tag to create a global Ls object, or omit to inject directly into window.","message":"When using the UMD build with a script tag, the library is placed under the namespace specified by the data-lightstreamer-ns attribute. If omitted, it pollutes the global window object.","severity":"gotcha","affected_versions":">=9.0"},{"fix":"Use the core build instead (e.g., importScripts('path/to/lightstreamer-core.js')).","message":"The full library contains Widgets and Mobile Push Notifications modules which are not available in Web Workers. Using the full build in a worker throws errors.","severity":"gotcha","affected_versions":">=9.0"},{"fix":"Use the UMD minified build for direct browser usage, or configure your bundler to minify the output.","message":"CommonJS and ES Module builds are not minified; bundlers are expected to handle minification. Attempting to use them directly in a browser without bundling will fail.","severity":"gotcha","affected_versions":">=9.0"},{"fix":"Use new Subscription({mode:'MERGE', items:['item1'], fields:['field1']}) instead of positional arguments.","message":"The 'Subscription' constructor signature with mode, items, fields is still supported but the recommended pattern is to use the options object.","severity":"deprecated","affected_versions":">=9.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add data-lightstreamer-ns='Ls' to the script tag, or change code to use window.LightstreamerClient directly.","cause":"The UMD script tag is missing the data-lightstreamer-ns attribute, but code references Ls.LightstreamerClient.","error":"Uncaught ReferenceError: Ls is not defined"},{"fix":"Use the UMD build with a script tag, or add type='module' to the script tag and use an importmap or bundler.","cause":"The library's ES module build is loaded via a script tag without type='module' or in a non-module context.","error":"Cannot use 'import' statement outside a module"},{"fix":"Ensure you call client.connect() before client.subscribe(sub), and check client status via client.addListener({onStatusChange}).","cause":"Calling subscribe before connect() or after disconnect() without a valid session.","error":"Error: No client found for session"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}