Skip to content

Instantly share code, notes, and snippets.

@zdunecki
Last active September 30, 2024 20:31
Show Gist options
  • Select an option

  • Save zdunecki/276bba1cad4242a4079ffe631d6cdfac to your computer and use it in GitHub Desktop.

Select an option

Save zdunecki/276bba1cad4242a4079ffe631d6cdfac to your computer and use it in GitHub Desktop.
LiveSession + Next.js
"use client"
// pages/_app.js
import { useEffect } from "react"
import ls from "@livesession/sdk"
// Check if LiveSession is client-side (used to handle Next.js SSR)
if (typeof window !== 'undefined') {
ls.init(process.env.NEXT_PUBLIC_LIVESESSION_TRACK_ID, {
// SDK options (https://github.com/livesession/livesession-sdk)
})
}
export default function LiveSessionScript() {
useEffect(() => {
ls.newPageView();
}, [])
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment