Add a website feedback widget to Next.js
Add next/script to your root layout. Works with the App Router and the Pages Router. Clients you invite then click anything on the site and leave a note, with a screenshot, the page and their browser attached. Everyone else sees nothing.
Updated
Before you start
- Create a free Pinnote account and add your site. Its settings show your line of code, under Install, with your own site key in place of
pk_…. - Access to the site's code.
<script src="https://pinnote.app/widget.js" data-project="pk_…" async></script>Add it to Next.js
- In the App Router, open
app/layout.tsxand add the script inside<body>. Next.js passesdata-*attributes through to the tag, and the default strategy,afterInteractive, is the right one. - In the Pages Router, add the same
<Script>topages/_app.tsx. - Deploy.
app/layout.tsx
import Script from "next/script";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
<Script src="https://pinnote.app/widget.js" data-project="pk_…" />
</body>
</html>
);
}Check it works
In Pinnote, open your site's settings and, under Install, click Try it on my site. It opens your site signed in as a reviewer; the Feedback button appears in the corner, and Install turns to "Installed". Then invite your client by email. They click the link and can comment straight away, with no account.
Preview deployments (Vercel, Netlify) each have their own address. Add the ones clients review on under Other addresses in your site's settings in Pinnote.
If it doesn't show up
- If your site sets a Content Security Policy, allow
https://pinnote.appinscript-src(or pass your nonce to the Script) andconnect-src, plusdata:andblob:inimg-srcfor screenshots. To sign clients in through your own app instead of email invites, see the identity token steps under Install in your site's settings in Pinnote. - Check who gets the button on your site's People page. Open the site from an invite, your share link or Try it on my site to see it as an invited person; a private window shows what visitors see.