Registry / http-networking / braid-http

braid-http

JSON →
library1.3.125jsnpmunverified

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.

npm install braid-http
INSTALL
IMPORT
SIG · BRAID-HTTP
B
braid-http
http-networkingjavascriptv1.3.125
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetch
✓ import { fetch } from 'braid-http'
✗ const braid = require('braid-http'); braid.fetch()
Default export not available; named import required. In CJS, use destructuring.
http_client
✓ import { http_client } from 'braid-http'
✗ import http_client from 'braid-http'
Not a default export; always named import.
http_server
✓ import { http_server } from 'braid-http'
✗ const { http_server } = require('braid-http')
Also works with require destructuring.

Demonstrates subscribing to a resource with automatic reconnection.

import { fetch } from 'braid-http' async function subscribeToChat() { const response = await fetch('https://braid.org/chat', { subscribe: true, retry: true }) response.subscribe((update) => { console.log('New update:', update) }) } subscribeToChat()
Debug
Known issues
gotchaThe 'braid-http' module does not export a default; always use named imports.
fix
Use 'import { fetch } from 'braid-http'' instead of 'import braidFetch from 'braid-http''.
affects: >=0.0.0
gotchaBrowser usage requires a script tag with unpkg. The global 'braid_fetch' is the replacement for window.fetch.
fix
Use <script src='https://unpkg.com/braid-http/braid-http-client.js'></script> then window.fetch = braid_fetch.
affects: >=0.0.0
gotchaThe 'response.subscribe' callback receives an update object that may contain 'patches' or 'body', but not both. Check for existence of 'patches' to differentiate.
fix
Use 'if (update.patches) { ... } else { ... }' to handle patches vs. full body.
affects: >=0.0.0
gotchaThe 'parents' option in fetch can be a function returning current parents, not just a static array.
fix
Set 'parents: () => current_parents' to dynamically update version on reconnect.
affects: >=0.0.0
gotchaNode.js usage requires installing the package and importing via require or ESM.
fix
Use 'const { fetch } = require('braid-http')' for CJS or 'import { fetch } from 'braid-http'' for ESM.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'braid-http'
Package not installed or incorrectly imported.
fix
Run 'npm install braid-http' and ensure import path is correct.
TypeError: braid_http.fetch is not a function
Using default import instead of named import.
fix
Use 'import { fetch } from 'braid-http'' instead of 'import braid_http from 'braid-http''.
Uncaught ReferenceError: braid_fetch is not defined
Script tag missing or not loaded before execution.
fix
Include <script src='https://unpkg.com/braid-http/braid-http-client.js'></script> before calling braid_fetch.
Failed to fetch: The 'subscribe' option is not supported by this version of fetch
Using native browser fetch instead of braid-http's fetch.
fix
Ensure you are using the braid-http fetch: 'import { fetch } from 'braid-http''.
Upgrade
Version history
1.3.125latest on npm
Audit
Dependencies
fetch-ponyfillrequiredUsed internally for fetch ponyfill in browsers
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
braid-http — npm install braid-http · libregistry