Skip to content

Releases: wingify/vwo-smartcode-nextjs

Version 1.2.0

18 Mar 11:20
Compare
Choose a tag to compare

[1.2.0] - 2024-03-18

Changed

  • refactor: peerDependencies to support Next.js 9+ and React 16.8+ (#1)

Version 1.1.0

04 Mar 08:17
Compare
Choose a tag to compare

[1.0.0] - 2025-03-03

Added

  • First release of Next.js component for VWO Smart-code

    Usage

    Page Router (Legacy pages/ Directory)

    For applications using the Page Router, add the VWOScript component inside _document.js (or _document.tsx if using TypeScript) to include it in the <head> of your HTML document.

    // pages/_document.js
    import Document, { Html, Head, Main, NextScript } from 'next/document';
    import { VWOScript } from 'vwo-smartcode-nextjs';
    
    class MyDocument extends Document {
      render() {
        return (
          <Html>
            <Head>
              <VWOScript accountId="YOUR_ACCOUNT_ID" />
            </Head>
            <body>
              <Main />
              <NextScript />
            </body>
          </Html>
        );
      }
    }
    
    export default MyDocument;

    App Router (app/ Directory)

    For applications using the App Router, include the VWOScript component in layout.tsx to ensure it loads correctly within the <head> of your HTML document.

    // app/layout.tsx
    import { VWOScript } from 'vwo-smartcode-nextjs';
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      return (
        <html lang="en">
          <head>
            <VWOScript accountId="YOUR_ACCOUNT_ID" />
          </head>
          <body>{children}</body>
        </html>
      );
    }

    Using Nonce

    To add a nonce attribute for Content Security Policy:

    <VWOScript
      accountId="YOUR_ACCOUNT_ID"
      scriptAttributes={{
        nonce: 'your-nonce-value',
      }}
    />

Version 1.0.0

03 Mar 08:59
Compare
Choose a tag to compare

[1.0.0] - 2025-03-03

Added

  • First release of Next.js component for VWO Smart-code

    Usage

    Page Router (Legacy pages/ Directory)

    For applications using the Page Router, add the VWOScript component inside _document.js (or _document.tsx if using TypeScript) to include it in the <head> of your HTML document.

    // pages/_document.js
    import Document, { Html, Head, Main, NextScript } from 'next/document';
    import { VWOScript } from 'vwo-smartcode-nextjs';
    
    class MyDocument extends Document {
      render() {
        return (
          <Html>
            <Head>
              <VWOScript accountId="YOUR_ACCOUNT_ID" />
            </Head>
            <body>
              <Main />
              <NextScript />
            </body>
          </Html>
        );
      }
    }
    
    export default MyDocument;

    App Router (app/ Directory)

    For applications using the App Router, include the VWOScript component in layout.tsx to ensure it loads correctly within the <head> of your HTML document.

    // app/layout.tsx
    import { VWOScript } from 'vwo-smartcode-nextjs';
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      return (
        <html lang="en">
          <head>
            <VWOScript accountId="YOUR_ACCOUNT_ID" />
          </head>
          <body>{children}</body>
        </html>
      );
    }

    Using Nonce

    To add a nonce attribute for Content Security Policy:

    <VWOScript
      accountId="YOUR_ACCOUNT_ID"
      scriptAttributes={{
        nonce: 'your-nonce-value',
      }}
    />