Skip to content
API/<QubeeFetchProvider>

<QubeeFetchProvider>

component
src/components/qubee-fetch-provider.tsx1 parameter

Set what performs the requests of every fetching hook below it — useQubeeQuery, and useQubeeSWR from the SWR entry.

Without a provider the hooks use the global fetch. A hook given its own fetcher uses that one; the nearest provider wins over the ones above it. In a Next.js server layout, render it inside a Client Component of your own: a function cannot cross the server–client boundary as a prop.

import { QubeeFetchProvider } from '@qubeejs/react';
function QubeeFetchProvider(props: QubeeFetchProviderProps): ReactElement
Parameter Type Description
props QubeeFetchProviderProps The fetcher, and the subtree

The subtree, with the fetcher in context

const authFetch: QubeeFetcher = (uri, init) =>
fetch(uri, { ...init, headers: { ...init.headers, Authorization: `Bearer ${token()}` } });
<QubeeFetchProvider fetcher={authFetch}>
<App />
</QubeeFetchProvider>

QubeeFetchProviderProps