New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@newskit-render/api

Package Overview
Dependencies
Maintainers
1
Versions
409
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newskit-render/api

helper package for accessing MAIN and NK API data

latest
npmnpm
Version
1.19.0
Version published
Weekly downloads
1.3K
-5.93%
Maintainers
1
Weekly downloads
 
Created
Source

@newskit-render/api

Helper package to make setting up and using Apollo Client with CPS (formerly Main) or NewsKit API easier.

Usage

createApolloClient

import { createApolloClient, ClientTypes } from '@newskit-render/api'

// MAIN with cookies
const mainApolloClient = await createApolloClient(
  ClientTypes.main,
  context.req.headers.cookie
)

// NKAPI with cookies
const nkApiApolloClient = await createApolloClient(
  ClientTypes.nkapi,
  context.req.headers.cookie
)

// NKAPI without cookies
const apolloClient = await createApolloClient(ClientTypes.nkapi)

// pass custom set up
const apolloClient = await createApolloClient({
  initialState: {},
  uri: process.env.NEWSKIT_API_ENV_URL,
  headers: {
    'x-api-key': process.env.NEWSKIT_API_X_API_KEY,
  },
  addTypename: false,
})

getApolloClient

import { getApolloClient } from '@newskit-render/api'

const shouldUseNewskitApi = true

const apolloClient = await getApolloClient(
  shouldUseNewskitApi,
  req.headers.cookie
)

helpers

  • getHeaders - creates header for MAIN
  • getAccessToken - access header used by MAIN
  • getMainSession - get MAIN session from cookie
  • sessionParser - decodes session id

Authentication environment variables

For MAIN and NewsKit API authentication see MAIN and NewsKit API. For Step-up MFA see @newskit-render/my-account

FAQs

Package last updated on 05 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts