Skip to main content

Nextjs

Integrate Segment into Nextjs app

import Document, { Html, Head, Main, NextScript } from 'next/document';
class PubNubDocument extends Document {
  static async getInitialProps(ctx) {
    const initialProps = await Document.getInitialProps(ctx);
         
    return { ...initialProps }
  }
  render() {
      
  
    return (
      <Html lang="en">

How to print ID and call on body dynamically Nextjs

import Document, { Html, Head, Main, NextScript } from 'next/document';
class PubNubDocument extends Document {
  static async getInitialProps(ctx) {
    const initialProps = await Document.getInitialProps(ctx);
         
    return { ...initialProps }
  }
  render() {
      
       //console.log(this.props.__NEXT_DATA__)
    return (
      &ltHtml lang="en">
        <Head />
        <body id="{this.props.__NEXT_DATA__.props.pageProps.bodyId}"  className="{this.props.__NEXT_DATA__.props.pageProps.bodyClass}" >
          <Main />