Relay

Installation

Relay ships as an ES module with TypeScript types included. It works anywhere the standard fetch API exists.

On this page

#Package managers

Pick your package manager. Your choice is remembered across every page of these docs.

npm install @relayhttp/relay

#Requirements

RuntimeMinimum versionNotes
Node.js18.0Uses the built-in fetch. No polyfill needed.
Deno1.35Import from npm:@relayhttp/relay.
Bun1.0Works out of the box.
BrowsersLast 2 versionsChrome, Edge, Firefox and Safari 15.4+.
Edge runtimes–Cloudflare Workers, Vercel Edge and Netlify Edge.

#Without a bundler

Load the module build straight from a CDN with a module script. This is handy for prototypes and plain HTML pages.

index.html
<script type="module">
  import relay from 'https://cdn.example.com/@relayhttp/relay@3.2.0/dist/relay.min.js';

  const status = await relay.get('/api/status').json();
  document.querySelector('#status').textContent = status.message;
</script>

#TypeScript

Types are bundled, so there's nothing extra to install. Pass a type parameter to .json() to type the response body:

user.ts
interface User {
  id: number;
  name: string;
  email: string;
}

const user = await relay.get('users/42').json<User>();
user.email; // string

#Deno

main.ts
import relay from 'npm:@relayhttp/relay@3';

const { version } = await relay.get('https://api.example.com/version').json();

#Verify the install

Run this one-liner to check that Relay loads and can reach the network:

Terminal
node -e "import('@relayhttp/relay').then(m => m.default.get('https://httpbin.org/get').json()).then(r => console.log('ok', r.url))"

Was this page helpful?

Edit this page on GitHub

Last updated

© 2026 Relay contributors. Released under the MIT License.

v3.2.0 · FAQ · GitHub