Install guides (31)
Add Ishara to Next.js
Add the feedback widget to a Next.js app with the Script component from next/script, in your root layout or your custom _app file.
- Where it goes
app/layout.tsx(orpages/_app.js)- Allowed domains
- Your own domain (set when you add the site)
- Time
- About 3 minutes
Steps
In Ishara, open Sites → your site → Install and copy the line under Add the line to your site. Your site’s key is already in it:
<script src="https://useishara.com/w.js" data-site="pk_…" defer></script>
In your root layout,
app/layout.tsx, importScriptfromnext/scriptand add it inside<body>, after{children}. Next.js forwards extra attributes such asdata-siteto the final<script>, and the root layout covers every route:import Script from "next/script"; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang="en"> <body> {children} <Script src="https://useishara.com/w.js" data-site="pk_…" strategy="afterInteractive" /> </body> </html> ); }Deploy the change as usual.
Open your site. Back on the Install page, Check it’s live turns into The widget is live as soon as the widget loads. Then open the Reviewer link from the same page: only people who open it see Leave a note.
Pages Router
With the Pages Router, add the same Script to your custom pages/_app.js, after the page component:
import Script from "next/script";
export default function MyApp({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Script src="https://useishara.com/w.js" data-site="pk_…" strategy="afterInteractive" />
</>
);
}Good to know
- Keep
strategyatafterInteractive(the default) orlazyOnload. Next.js keepsbeforeInteractivefor scripts such as bot detectors and cookie consent managers. - The root layout can stay a Server Component: a
Scriptwithout event handlers such asonLoaddoesn’t need"use client". - If you send a Content Security Policy with a nonce, pass
nonce={nonce}toScript, or allow the widget’s origin inscript-src(details).
Next
Once reviewers leave notes, your coding agent can apply them. The widget’s options (language, position, colour, launcher) are in the docs.