{"id":18175,"library":"braid-http","title":"Braid-HTTP","description":"A ponyfill library extending browser and Node.js HTTP implementations to support Braid-HTTP, turning state transfer into state synchronization. Currently at version 1.3.125, with regular releases. Key differentiators: drop-in replacement for fetch() in browsers, adds capabilities to Node.js http/https/http2 modules, conforms to Braid-HTTP v04 spec with HTTP Multiresponse and Multiplexing extensions. Compared to alternatives, this is the primary implementation of the Braid protocol, providing subscription-based real-time updates and automatic reconnection.","status":"active","version":"1.3.125","language":"javascript","source_language":"en","source_url":"https://github.com/braid-org/braid-http","tags":["javascript","typescript"],"install":[{"cmd":"npm install braid-http","lang":"bash","label":"npm"},{"cmd":"yarn add braid-http","lang":"bash","label":"yarn"},{"cmd":"pnpm add braid-http","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for fetch ponyfill in browsers","package":"fetch-ponyfill","optional":false}],"imports":[{"note":"Default export not available; named import required. In CJS, use destructuring.","wrong":"const braid = require('braid-http'); braid.fetch()","symbol":"fetch","correct":"import { fetch } from 'braid-http'"},{"note":"Not a default export; always named import.","wrong":"import http_client from 'braid-http'","symbol":"http_client","correct":"import { http_client } from 'braid-http'"},{"note":"Also works with require destructuring.","wrong":"const { http_server } = require('braid-http')","symbol":"http_server","correct":"import { http_server } from 'braid-http'"}],"quickstart":{"code":"import { fetch } from 'braid-http'\n\nasync function subscribeToChat() {\n  const response = await fetch('https://braid.org/chat', {\n    subscribe: true,\n    retry: true\n  })\n  response.subscribe((update) => {\n    console.log('New update:', update)\n  })\n}\n\nsubscribeToChat()","lang":"typescript","description":"Demonstrates subscribing to a resource with automatic reconnection."},"warnings":[{"fix":"Use 'import { fetch } from 'braid-http'' instead of 'import braidFetch from 'braid-http''.","message":"The 'braid-http' module does not export a default; always use named imports.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use <script src='https://unpkg.com/braid-http/braid-http-client.js'></script> then window.fetch = braid_fetch.","message":"Browser usage requires a script tag with unpkg. The global 'braid_fetch' is the replacement for window.fetch.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'if (update.patches) { ... } else { ... }' to handle patches vs. full body.","message":"The 'response.subscribe' callback receives an update object that may contain 'patches' or 'body', but not both. Check for existence of 'patches' to differentiate.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set 'parents: () => current_parents' to dynamically update version on reconnect.","message":"The 'parents' option in fetch can be a function returning current parents, not just a static array.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'const { fetch } = require('braid-http')' for CJS or 'import { fetch } from 'braid-http'' for ESM.","message":"Node.js usage requires installing the package and importing via require or ESM.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install braid-http' and ensure import path is correct.","cause":"Package not installed or incorrectly imported.","error":"Cannot find module 'braid-http'"},{"fix":"Use 'import { fetch } from 'braid-http'' instead of 'import braid_http from 'braid-http''.","cause":"Using default import instead of named import.","error":"TypeError: braid_http.fetch is not a function"},{"fix":"Include <script src='https://unpkg.com/braid-http/braid-http-client.js'></script> before calling braid_fetch.","cause":"Script tag missing or not loaded before execution.","error":"Uncaught ReferenceError: braid_fetch is not defined"},{"fix":"Ensure you are using the braid-http fetch: 'import { fetch } from 'braid-http''.","cause":"Using native browser fetch instead of braid-http's fetch.","error":"Failed to fetch: The 'subscribe' option is not supported by this version of fetch"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}