@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>
50 lines (47 loc) • 1.9 kB
JavaScript
import { WrapApolloProvider, ApolloClient as ApolloClient$1, InMemoryCache as InMemoryCache$1 } from '@apollo/client-react-streaming';
export { DebounceMultipartResponsesLink, RemoveMultipartDirectivesLink, SSRMultipartLink } from '@apollo/client-react-streaming';
import { useContext } from 'react';
import { buildManualDataTransport, resetManualSSRApolloSingletons } from '@apollo/client-react-streaming/manual-transport';
import { ServerInsertedHTMLContext } from 'next/navigation.js';
// src/index.shared.ts
// src/bundleInfo.ts
var bundle = {
pkg: "@apollo/client-integration-nextjs",
client: "ApolloClient",
cache: "InMemoryCache"
};
var ApolloClient = class extends ApolloClient$1 {
/**
* Information about the current package and it's export names, for use in error messages.
*
* @internal
*/
static info = bundle;
};
var InMemoryCache = class extends InMemoryCache$1 {
/**
* Information about the current package and it's export names, for use in error messages.
*
* @internal
*/
static info = bundle;
};
var ApolloNextAppProvider = /* @__PURE__ */ WrapApolloProvider(
buildManualDataTransport({
useInsertHtml() {
const insertHtml = useContext(ServerInsertedHTMLContext);
if (!insertHtml) {
throw new Error(
'The SSR build of ApolloNextAppProvider cannot be used outside of the Next App Router!\nIf you encounter this in a test, make sure that your tests are using the browser build by adding the "browser" import condition to your test setup.'
);
}
return insertHtml;
}
})
);
ApolloNextAppProvider.info = bundle;
var resetApolloClientSingletons = resetManualSSRApolloSingletons;
const built_for_ssr = true;
export { ApolloClient, ApolloNextAppProvider, InMemoryCache, built_for_ssr, resetApolloClientSingletons };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.ssr.js.map