💎
Headless Docs
Version 0.2.0
Version 0.2.0
  • Overview
  • Change Log
  • Next.js Steps
    • Requirements
    • Determine Page Methods
      • Route Hashing Method
      • Cookies Method
    • Install Middleware
    • Add Intelligems Provider
    • Read User Context
      • Route Hashing Method
      • Cookies Method
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Gatsby Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Pack Digital Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Examples
    • Content Testing
  • Reference
    • Middleware Objects
      • IgMiddlewareConfig
      • IgMiddlewareHandler
    • Providers
      • Next.js
      • Gatsby
    • Components
      • Price Components
    • Hooks
      • Price Hooks
      • Track Hooks
      • Experiment Hooks
      • Test Group Hooks
      • Cart & Checkout Hooks
Powered by GitBook
On this page
  • Update getServerSideProps
  • Example Configuration
  1. Next.js Steps
  2. Read User Context

Cookies Method

Update getServerSideProps

User Context is restored within getServerSideProps through the following steps:

  1. This context is immediately parsed at the top of the getServerSideProps function.

  2. The Intelligems config is pulled from our CDN.

  3. The User Context, the Intelligems config, and all other page props are merged and returned as props.

Example Configuration

import { withIntelligemsProps, IgCookiesContext } from '@intelligems/headless/next'

export const getServerSideProps = async ({
  req,
  preview,
  locale,
  locales,
}: GetServerSidePropsContext) => {
  const igContext = IgCookiesContext.getUserContext(req)
  
  const categories = ...
  const pages = ...

    ...
    ...
    
  const finalProps = await withIntelligemsProps({
      products,
      categories,
      brands,
      pages,
    },
    igContext
  )

  return {
    props: finalProps,
  }
}
PreviousRoute Hashing MethodNextTrack Page Views