Skip to content

Start typing to search the documentation.

createFlueClient(...)

AI-generated, awaiting review View as Markdown
import { createFlueClient } from '@flue/sdk';

const client = createFlueClient({
  baseUrl: 'https://example.com/api',
  token: process.env.FLUE_TOKEN,
});

In a browser, baseUrl may be relative to location.origin. This is the usual same-origin setup:

const client = createFlueClient({ baseUrl: '/api' });

Outside a browser, baseUrl must be absolute; a relative value throws an error.

createFlueClient(...)

function createFlueClient(options: CreateFlueClientOptions): FlueClient;

Creates a client for the public routes of a deployed Flue application.

CreateFlueClientOptions

FieldTypeDefaultDescription
baseUrlstringURL where the public flue() sub-app is mounted, including any pathname. Browser clients may use a relative URL.
fetchtypeof fetchglobal fetchCustom HTTP implementation. Also used for Durable Streams event streaming.
headersRequestHeadersHeaders merged into each HTTP and stream request.
tokenstringBearer token added to HTTP and stream requests.

RequestHeaders

type RequestHeaders =
  | Record<string, string>
  | (() => Record<string, string> | Promise<Record<string, string>>);

Use a function to resolve headers separately for each HTTP request and stream reconnection.