Open the console

Embedding an onboarding checklist in a Next.js App Router app

App Router's server components change where this widget can live. Here is the client boundary it needs and the one hydration mistake to avoid.

Embedding an onboarding checklist in a Next.js App Router app

Next.js's App Router renders components on the server by default, and the onboarding checklist widget — a script that mounts a custom element and talks to the DOM — cannot run there. The integration work is entirely about drawing the client boundary in the right place, not about the widget itself, which has no App Router-specific behavior to configure.

Marking the boundary

A component that mounts the checklist needs 'use client' at the top of its file, and the script load needs to happen inside useEffect, not at module scope or during render, since module-level code in a client component still runs during the server's first pass in some rendering paths:

'use client';
import { useEffect } from 'react';

export function Onboarding({ userId }: { userId: string }) {
  useEffect(() => {
    const s = document.createElement('script');
    s.src = 'https://gettingstarted.marthaia.com/embed.js';
    s.defer = true;
    document.body.appendChild(s);
  }, []);

  return <gs-checklist project="your-project-id" user-id={userId} />;
}

Where to put this component in the tree

Keep the client boundary as narrow as possible — a dedicated Onboarding component imported into a layout or page, rather than marking an entire layout 'use client' just to host the checklist. App Router's value is server-rendering everything that does not need interactivity; a checklist widget is the one piece in a layout that does, and it should not drag the rest of that layout into the client bundle with it.

TypeScript and the custom element

TypeScript does not know about gs-checklist by default and will flag it as an unknown JSX intrinsic. Extend the JSX namespace once, in a declaration file, rather than suppressing the error inline every time the tag is used:

declare namespace JSX {
  interface IntrinsicElements {
    'gs-checklist': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      project?: string; 'user-id'?: string;
    };
  }
}

What not to do

Do not try to server-render the checklist's initial state to avoid a layout shift. The widget's state call is inherently client-side — it needs the actual signed-in user's id, which a server component typically does not have without its own auth plumbing — and attempting to pre-fetch it server-side just duplicates the widget's own fetch for no benefit.

What to measure instead of guessing

Nobody has measured whether App Router's streaming SSR makes the checklist appear meaningfully faster or slower than a client-rendered SPA equivalent — check your own Largest Contentful Paint and Total Blocking Time rather than assuming either direction. What is concretely worth checking: that the script tag is not duplicated across client-side navigations, which App Router's layout caching can cause if the mounting useEffect is not scoped correctly.

See the docs for the embed script reference, and the live preview for a working instance.

Try it on your app