UNPKG

@apollo/client-integration-nextjs

Version:

<div align="center"> <img src="https://raw.githubusercontent.com/apollographql/apollo-client-integrations/main/banner.jpg" width="500" alt="Apollo Client + Next.js App Router" /> </div>

110 lines (105 loc) 3.59 kB
import * as _apollo_client_react_streaming from '@apollo/client-react-streaming'; import { ApolloClient as ApolloClient$1, InMemoryCache as InMemoryCache$1 } from '@apollo/client-react-streaming'; export { DebounceMultipartResponsesLink, RemoveMultipartDirectivesLink, SSRMultipartLink, TransportedQueryRef } from '@apollo/client-react-streaming'; import * as _apollo_client_react_streaming_manual_transport from '@apollo/client-react-streaming/manual-transport'; import { resetManualSSRApolloSingletons } from '@apollo/client-react-streaming/manual-transport'; /** @public */ declare namespace ApolloClient { /** @public */ interface Options extends ApolloClient$1.Options { } } /** * A version of `ApolloClient` to be used with streaming SSR or in React Server Components. * * For more documentation, please see {@link https://www.apollographql.com/docs/react/api/core/ApolloClient | the Apollo Client API documentation}. * * @public */ declare class ApolloClient extends ApolloClient$1 { /** * Information about the current package and it's export names, for use in error messages. * * @internal */ static readonly info: { pkg: string; client: string; cache: string; }; } /** * A version of `InMemoryCache` to be used with streaming SSR. * * For more documentation, please see {@link https://www.apollographql.com/docs/react/api/cache/InMemoryCache | the Apollo Client API documentation}. * * @public */ declare class InMemoryCache extends InMemoryCache$1 { /** * Information about the current package and it's export names, for use in error messages. * * @internal */ static readonly info: { pkg: string; client: string; cache: string; }; } /** * > This export is only available in React Client Components * * A version of `ApolloProvider` to be used with the Next.js App Router. * * As opposed to the normal `ApolloProvider`, this version does not require a `client` prop, * but requires a `makeClient` prop instead. * * Use this component together with `ApolloClient` and `InMemoryCache` * from the `"@apollo/client-integration-nextjs"` package * to make an ApolloClient instance available to your Client Component hooks in the * Next.js App Router. * * @example * `app/ApolloWrapper.jsx` * ```tsx * import { HttpLink } from "@apollo/client"; * import { ApolloNextAppProvider, ApolloClient, InMemoryCache } from "@apollo/client-integration-nextjs"; * * function makeClient() { * const httpLink = new HttpLink({ * uri: "https://example.com/api/graphql", * }); * * return new ApolloClient({ * cache: new InMemoryCache(), * link: httpLink, * }); * } * * export function ApolloWrapper({ children }: React.PropsWithChildren) { * return ( * <ApolloNextAppProvider makeClient={makeClient}> * {children} * </ApolloNextAppProvider> * ); * } * ``` * * @public */ declare const ApolloNextAppProvider: _apollo_client_react_streaming.WrappedApolloProvider<_apollo_client_react_streaming_manual_transport.HydrationContextOptions>; /** * > This export is only available in React Client Components * * Resets the singleton instances created for the Apollo SSR data transport and caches. * * To be used in testing only, like * ```ts * afterEach(resetApolloClientSingletons); * ``` * * @public */ declare const resetApolloClientSingletons: typeof resetManualSSRApolloSingletons; export { ApolloClient, ApolloNextAppProvider, InMemoryCache, resetApolloClientSingletons };