@pack/client

The @pack/client package provides a javascript client for interacting with the Pack GraphQL API.

Quick Start

Install the client with a package manager:

npm install @pack/client

Import and create a new client instance, and use its methods to interact with your project's Content Lake. Below are some simple examples in plain JavaScript. Read further for more comprehensive documentation.

Example

import { PackClient } from '@pack/client'

const packClient = new PackClient({
  apiUrl: 'https://app.packdigital.com/graphql', // if you exclude this we will use our CDN API https://apicdn.packdigital.com/graphql
  token: process.env.PACK_SECRET_TOKEN,
  contentEnvironment: 'content_environment_handle', // if you exclude this we will default to the primary content environment
})

await packClient.fetch(query, { variables: queryVariables })
interface PackClientOptions {
  /** Pack API token */
  token: string
  /** The content environment handle */
  contentEnvironment?: string
  /** The URL of the Pack GraphQL API */
  apiUrl?: string
}

Resources

GraphQL CMS API

Learn more about our GraphQL content APIs

Was this page helpful?