# 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` (or `pages/_app.js`)
- Allowed domains: your own domain
- Time: about 3 minutes

## Steps

1. 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:

```html
<script src="https://useishara.com/w.js" data-site="pk_…" defer></script>
```

2. In your root layout, `app/layout.tsx`, import `Script` from `next/script` and add it inside `<body>`, after `{children}`. Next.js forwards extra attributes such as `data-site` to 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>
  );
}
```

3. Deploy the change as usual.
4. 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 `strategy` at `afterInteractive` (the default) or `lazyOnload`. Next.js keeps `beforeInteractive` for scripts such as bot detectors and cookie consent managers.
- The root layout can stay a Server Component: a `Script` without event handlers such as `onLoad` doesn’t need `"use client"`.
- If you send a Content Security Policy with a nonce, pass `nonce={nonce}` to `Script`, or allow the widget’s origin in `script-src` ([details](https://useishara.com/docs#csp)).

Checked against the official docs on 2026-11-12: [Next.js: Script component](https://nextjs.org/docs/app/api-reference/components/script), [Next.js: scripts (App Router)](https://nextjs.org/docs/app/guides/scripts), [Next.js: scripts (Pages Router)](https://nextjs.org/docs/pages/guides/scripts), [Next.js: Content Security Policy](https://nextjs.org/docs/app/guides/content-security-policy).
