Skip to main content
Version: v1

Constants

You may place this file in any directory where you typically hold constants, in NextJS environment variables, or in a new component directory for Beam widgets. In this example, let’s add the Beam constants as a new file inside a directory for the Beam-related widget code, at src/app/components/beam/

Base code

File: src/app/components/beam/constants.ts

Replace the following in the example

  • BEAM_PUBLIC_API_KEY - Your Beam SDK API Key (string)
  • BEAM_CHAIN_ID - Your Beam Chain Id (number)
  • BEAM_STORE_ID - Your Beam Store Id (number)
  • BEAM_STORE_TOP_DOMAIN - Your website’s top-level domain (string, eg: “myshop.com”, not “https://myshop.com”). If your site uses different subdomains between your public storefront and your checkout flow (ie: myshop.com and checkout.myshop.com), this setting allows for storing nonprofit selections between each subdomain. In many instances, this value is available in an environment variable; in that case, pull in the value from the environment variable.
  • BEAM_STATSIG_CLIENT_KEY - Your Statsig Client API Key (string, optional). If you are implementing Statsig to AB test Beam on your site, set your provided client key here.
// Beam core variables:
export const BEAM_PUBLIC_API_KEY = '{{ SDK API Key }}'
export const BEAM_CHAIN_ID = {{ Chain Id }}
export const BEAM_STORE_ID = {{ Store Id }}
export const BEAM_STORE_TOP_DOMAIN = '{{ Store Top Domain }}'
export const BEAM_SESSION_ID_COOKIE = 'beam_session'

// If using a Beam staging account, configure the base URL below
// (IDs above will be different between staging and production):
export const BEAM_BASE_URL = 'https://api.beamimpact.com'
export const BEAM_LOG_URL = 'https://production.beamimpactlogs.com'

// For Statsig A/B test, if applicable:
export const BEAM_STATSIG_CLIENT_KEY = '{{ Statsig Client Key }}'
export const BEAM_CART_UPDATE_EVENT_NAME = 'BEAM_CART_UPDATE_EVENT'
export const BEAM_LOG_STATSIG_EVENT_NAME = 'BEAM_LOG_STATSIG_EVENT'
export const BEAM_SAVE_REMOTE_SESSION_EVENT_NAME = 'BEAM_SAVE_REMOTE_SESSION_EVENT'