Last active
September 30, 2024 20:31
-
-
Save zdunecki/276bba1cad4242a4079ffe631d6cdfac to your computer and use it in GitHub Desktop.
LiveSession + Next.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "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