@cmpsr/contentful-core
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

contentful-core

A utility package providing the createContentfulLink method for setting up a link with Apollo Client in React/Next.js applications using Contentful.

Install

Install the package using Yarn:

yarn add @cmpsr/contentful-core

Usage

createContentfulLink

This method creates an Apollo Client HttpLink for connecting to Contentful's GraphQL API.

Here's how to use createContentfulLink to configure Apollo Client in a Next.js application:

import { ApolloClient, InMemoryCache } from "@apollo/client";
import { createContentfulLink } from "@cmpsr/contentful-core";

const apolloClient = new ApolloClient({
  link: createContentfulLink({
    space: process.env.CONTENTFUL_SPACE_ID,
    accessToken: process.env.CONTENTFUL_ACCESS_TOKEN_DELIVERY,
  }),
  cache: new InMemoryCache(),
});

export default apolloClient;

Readme

Keywords

none

Package Sidebar

Install

npm i @cmpsr/contentful-core

Weekly Downloads

3,485

Version

1.0.0

License

MIT

Unpacked Size

6.53 kB

Total Files

8

Last publish

Collaborators

  • stevejcox
  • tkanzakic
  • ryanhefner