AVAILABLE: next/script Optimized

High-Performance Next.js App Router & Pages Router Integration

Deploy Rajlav AI with zero impact on Next.js Core Web Vitals. Utilize `next/script` with `strategy="afterInteractive"` for flawless Server-Side Rendering (SSR) and static generation.

Method: Next.js `next/script` with `strategy="afterInteractive"`•Verified Next.js App Router & Pages Router Compatibility
Next.js App Router layout.tsx ExampleAsynchronous • Zero Render Blocking
import Script from 'next/script';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://staging.rajlav.co.in/widget/smart-connect.js"
          data-business-id={process.env.NEXT_PUBLIC_RAJLAV_BUSINESS_ID}
          data-position="bottom-right"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}
Why Integrate Rajlav AI

Engineered for Performance & Scalability

01

Core Web Vitals Safe

Loads after hydration completes, ensuring 100/100 Lighthouse performance scores.

02

App Router & Pages Router

Fully compatible with Next.js 14, 15, root layouts (`layout.tsx`), and classic `_app.tsx`.

03

Zero Hydration Mismatch

Engineered to avoid React hydration errors and DOM mutation warnings during mount.

04

Route Change Persistence

Maintains open chat sessions seamlessly across soft page navigations.

Quickstart Guide

How to Connect Next.js in 4 Steps

01

Import Script in layout.tsx

Import `Script` from `next/script` inside your root `app/layout.tsx` file.

02

Configure Attributes

Set `src`, `data-business-id`, and `strategy="afterInteractive"`.

03

Set Environment Variables

Optionally store your Business ID in `process.env.NEXT_PUBLIC_RAJLAV_BUSINESS_ID`.

04

Deploy to Vercel or Node

Runs cleanly on Vercel, AWS Amplify, Docker, and standard Node servers.

Compatibility Matrix

Compatible Rajlav AI Modules

✓ Smart Connect Widget✓ AI Website Chatbot✓ Lead Qualification✓ Unified CRM Inbox✓ REST API & Webhooks
Integration Support

Frequently Asked Questions

Will this cause Next.js hydration mismatch errors?

No! Because `next/script` with `afterInteractive` executes strictly on the client post-hydration, there is zero risk of hydration mismatches.

Does it work with static site generation (SSG) and ISR?

Yes! Completely compatible with static generation (`output: export`), ISR, and dynamic server rendering.

Can I disable the widget on specific Next.js subpaths like /admin?

Yes! You can conditionally render the `<Script />` component based on the active pathname using `usePathname()`.