apollo-next
v1.0.6
Published
Apollo HOC for Next.js
Downloads
16
Readme
apollo-next
Apollo HOC for Next.js.
How to use
Install the package with npm:
npm install apollo-nextor with yarn:
yarn add apollo-nextimport withApollo from 'apollo-next';
import { ApolloClient, ApolloLink, ApolloProvider, InMemoryCache } from '@apollo/client';
export default withApollo(
({ initialState }) => {
return new ApolloClient({
uri: 'https://mysite.com/graphql',
cache: new InMemoryCache().restore(initialState || {})
});
},
{
render: ({ Page, props }) => {
return (
<ApolloProvider client={props.apollo}>
<Page {...props} />
</ApolloProvider>
);
}
}
);