Skip to content
We've just launched - check out our docs! đź“—
  • React
  • Client

Client

The livepeer Client is a framework agnostic client that manages state and connection to a Livepeer provider. The createReactClient function wraps the Client with a React-specific caching layer for faster queries.

import { createReactClient } from '@livepeer/react';

Usage

import { createReactClient, studioProvider } from '@livepeer/react';
 
const client = createReactClient({
  provider: studioProvider({ apiKey: 'yourStudioApiKey' }),
});

Configuration

provider

Livepeer provider interface for connecting to the network.

import { createReactClient, studioProvider } from '@livepeer/react';
 
const client = createReactClient({
  provider: studioProvider({ apiKey: 'yourStudioApiKey' }),
});

storage (optional)

The default strategy to persist and cache data. Used for both state management and query caching. Defaults to window.localStorage.

import { createReactClient, studioProvider } from '@livepeer/react';
 
const client = createReactClient({
  provider: studioProvider({ apiKey: 'yourStudioApiKey' }),
  storage: createStorage({ storage: window.localStorage }),
});

queryClient (optional)

The react-query QueryClient used to cache/deduplicate queries. Defaults to caching for 24 hours and no retries.

import { createReactClient, studioProvider } from '@livepeer/react';
 
const client = createReactClient({
  provider: studioProvider({ apiKey: 'yourStudioApiKey' }),
  queryClient: new QueryClient({
    defaultOptions: {
      queries: {
        cacheTime: 1_000 * 60 * 60, // 1 hour
        retry: 100,
      },
    },
  }),
});