{"id":46998,"library":"atmosphere.js","title":"atmosphere.js","description":"Modern TypeScript client for the Atmosphere Framework, providing real-time communication via WebSocket, SSE, Long-Polling, Streaming, and WebTransport transports. Version 5.0.29 is the latest stable release. It is actively maintained with frequent updates. Key differentiators include full TypeScript type safety, tree-shakeable imports, optional React/Vue/Svelte integrations as peer dependencies, and automatic reconnection with exponential backoff. Compared to bare WebSocket, it offers transport fallback and protocol abstraction.","status":"active","version":"5.0.29","language":"javascript","source_language":"en","source_url":"https://github.com/Atmosphere/atmosphere","tags":["javascript","atmosphere","websocket","sse","server-sent-events","comet","long-polling","realtime","push","typescript"],"install":[{"cmd":"npm install atmosphere.js","lang":"bash","label":"npm"},{"cmd":"yarn add atmosphere.js","lang":"bash","label":"yarn"},{"cmd":"pnpm add atmosphere.js","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for React Native connectivity detection","package":"@react-native-community/netinfo","optional":true},{"reason":"Peer dependency for React integration","package":"react","optional":true},{"reason":"Peer dependency for React Native integration","package":"react-native","optional":true},{"reason":"Peer dependency for Svelte integration","package":"svelte","optional":true},{"reason":"Peer dependency for Vue integration","package":"vue","optional":true}],"imports":[{"note":"Default instance, pre-configured. ESM-only since v5.0.0.","wrong":"const atmosphere = require('atmosphere.js')","symbol":"atmosphere","correct":"import { atmosphere } from 'atmosphere.js'"},{"note":"Named class for creating custom instances. No default export.","wrong":"import Atmosphere from 'atmosphere.js'","symbol":"Atmosphere","correct":"import { Atmosphere } from 'atmosphere.js'"},{"note":"Type import for request options. Use 'import type' to avoid runtime overhead.","wrong":"import { AtmosphereRequest } from 'atmosphere.js'","symbol":"AtmosphereRequest","correct":"import type { AtmosphereRequest } from 'atmosphere.js'"}],"quickstart":{"code":"import { atmosphere } from 'atmosphere.js';\n\nconst subscription = await atmosphere.subscribe({\n  url: process.env.SERVER_URL ?? 'http://localhost:8080/chat',\n  transport: 'websocket',\n}, {\n  message: (response) => {\n    console.log('Received:', response.responseBody);\n  },\n  open: (response) => {\n    console.log('Connected with transport:', response.transport);\n  },\n  close: (response) => {\n    console.log('Connection closed');\n  },\n  error: (error) => {\n    console.error('Error:', error);\n  }\n});\n\nsubscription.push({ user: 'John', message: 'Hello World' });\n\nawait subscription.close();","lang":"typescript","description":"Creates a WebSocket subscription, sends a JSON message, and closes the connection."},"warnings":[{"fix":"Upgrade to v5 and adjust callbacks to match new signature.","message":"In v4, `atmosphere.subscribe()` returned a promise but had different callback signatures.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Use `import { atmosphere } from 'atmosphere.js'` or switch to dynamic import().","message":"ESM-only since v5 — CJS `require()` no longer works.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Avoid using `enableProtocol`; use default protocol handling.","message":"The `enableProtocol` option is deprecated and will be removed in v6.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Run `npm install @react-native-community/netinfo` for React Native projects.","message":"In React Native, `@react-native-community/netinfo` must be installed as a peer dependency.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Always specify `transport` when calling `subscribe()`.","message":"The `transport` option is required; if omitted, the library may throw or default incorrectly.","severity":"gotcha","affected_versions":">=5.0.0"}],"env_vars":null,"search_vec":"'5.0.29':25 'abstract':71 'activ':33 'atmospher':7,73 'atmosphere.js':1 'automat':56 'backoff':60 'bare':63 'client':4 'comet':80 'communic':13 'compar':61 'depend':54 'differenti':39 'event':79 'exponenti':59 'fallback':68 'framework':8 'frequent':36 'full':41 'import':48 'includ':40 'integr':51 'javascript':72 'key':38 'latest':28 'long':18,82 'long-pol':17,81 'maintain':34 'modern':2 'offer':66 'option':49 'peer':53 'poll':19,83 'protocol':70 'provid':9 'push':85 'react/vue/svelte':50 'real':11 'real-tim':10 'realtim':84 'reconnect':57 'releas':30 'safeti':44 'sent':78 'server':77 'server-sent-ev':76 'shakeabl':47 'sse':16,75 'stabl':29 'stream':20 'time':12 'transport':23,67 'tree':46 'tree-shak':45 'type':43 'typescript':3,42,86 'updat':37 'version':24 'via':14 'websocket':15,64,74 'webtransport':22","created_at":"2026-06-07T16:49:14.125987+00:00","updated_at":"2026-06-07T16:49:14.125987+00:00","problems":[{"fix":"Ensure `\"type\": \"module\"` in package.json or use `import { atmosphere } from 'atmosphere.js'`.","cause":"ESM-only package imported with `require()` or missing TypeScript module resolution.","error":"Error: Cannot find module 'atmosphere.js' or its corresponding type declarations."},{"fix":"Use `import { atmosphere } from 'atmosphere.js'` (named import).","cause":"Imported default instead of named export `atmosphere`.","error":"TypeError: atmosphere.subscribe is not a function"},{"fix":"Update to at least version 5.0.0.","cause":"Using an older version (<5.0.0) where `push` is not available or different name.","error":"Property 'push' does not exist on type 'Subscription'"},{"fix":"Install the package: `npm install @react-native-community/netinfo`.","cause":"Missing `@react-native-community/netinfo` peer dependency.","error":"ReactNative: NetInfo fetch error: undefined is not an object (evaluating 'NativeModules.RNCNetInfo.getCurrentState')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Atmosphere/atmosphere#readme","github":"https://github.com/Atmosphere/atmosphere","docs":null,"changelog":null,"pypi":null,"npm":"atmosphere.js","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}