Skip to main content

Add a Feedback Widget to a Next.js App

Published June 5, 2026

Add a site-wide feedback launcher to Next.js with one embed. Works with App Router and Pages Router without a client-side SDK.

Next.js application code with a feedback widget embed in the root layout

Add a feedback widget to a Next.js app by loading one async script in your root layout. It works on App Router and Pages Router without a React SDK. Create a FeedBlox site for your public URL, verify the domain, paste the snippet, and submit a test report from staging.

Next.js teams usually want feedback on both marketing pages and authenticated app routes. You do not need a wrapper package for the first version - next/script with afterInteractive is enough.

Next.js root layout file with script embed for site-wide feedback

App Router: Root Layout

Add the embed in app/layout.tsx so it loads on every route. Use next/script with strategy="afterInteractive" to avoid blocking hydration.

Place the script after {children} inside body so the launcher renders on marketing and app routes alike.

app/layout.tsx (excerpt)

import Script from 'next/script';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://feedblox.net/widget.js"
          data-site-id="YOUR_SITE_ID"
          data-token="YOUR_EMBED_TOKEN"
          data-position="bottom-right"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}
SaaS dashboard showing user plan metadata attached to feedback

Attach SaaS Metadata From the Client

After login, call FeedBlox.setMetadata from a client component so bug reports include plan, user ID, or release tag. Use opaque IDs only.

Mount the metadata component inside your authenticated layout so values update when the session changes.

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

export function FeedBloxMetadata({ userId, plan }) {
  useEffect(() => {
    if (typeof window.FeedBlox?.setMetadata !== 'function') return;
    window.FeedBlox.setMetadata({ userId, plan, framework: 'nextjs' });
  }, [userId, plan]);
  return null;
}
Vercel preview deployment URL with feedback widget testing

Preview and Production URLs

Verify domain ownership against the URL visitors actually use (Vercel preview or production). Submit a test report from a preview deployment before go-live.

If preview URLs change often, use a dedicated staging site in FeedBlox with its own embed token. FeedBlox Free includes three sites - enough for staging, preview, and production.

Founder adds site in dashboard, pastes one async script before body close, verifies domain, submits a test report from staging. Inbox row shows sentiment, page URL, and client debug.

Plain script tag alternative for Next.js feedback widget install

Plain Script Tag Alternative

You can paste the dashboard snippet directly if you prefer not to use next/script. Include preconnect for faster first load.

Pages Router teams can use the same snippet in pages/_document.tsx or _app.tsx.

<link rel="preconnect" href="https://feedblox.net" crossorigin />
<script src="https://feedblox.net/widget.js" async
  data-site-id="YOUR_SITE_ID"
  data-token="YOUR_EMBED_TOKEN"
  data-position="middle-right"
  data-offset-bottom="16"
  data-offset-side="16"></script>

Verify Capture on Staging

  1. Deploy with the embed on a staging or preview URL
  2. Open a page and trigger a controlled console error or failed fetch
  3. Submit feedback through the launcher
  4. Confirm inbox shows console, network, JS errors, and element trail
  5. Roll out to production routes once verified

Related Guides

Product: Developer bug reporting tool.

Also read: Developer feedback use case.

Related Posts

Product Guides

Abstract geometric console structure behind the signup call to action

Ship bug reports with console logs on every plan

New accounts get Pro free for your first month: unlimited reports, screenshots, recordings, webhooks, and collaborators. No credit card. After the trial, Free forever: 3 sites, 150 reports/month, no credit card.

Start Free

No credit card required