> ## Documentation Index
> Fetch the complete documentation index at: https://getkoala.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Koala with Next.js

> Learn how to use Koala to uncover visitor intent happening on your Next.js application.

## Install in `pages/_app.js`

The easiest way to install Koala on Next.js applications is to add it to the main `_app.js` file.

Copy the Koala snippet from your [workspace installation settings page](https://app.getkoala.com/goto/settings/install) and paste it into the [`Script` component](https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#inline-scripts).

```jsx pages/_app.js theme={null}
import Script from 'next/script'
 
export default function MyApp({ Component, pageProps }) {
  return (
    <>
      <Script
        id="koala-snippet" 
        dangerouslySetInnerHTML={{ 
          __html: `// Paste your Koala snippet here`
        }}
      />
      <Component {...pageProps} />
    </>
  )
}
```

Alternatively, you can install Koala in the `<head>` or `<body>` of your site by adding the snippet to the `pages/_document.js` file.

```jsx pages/_document.js theme={null}
import { Head, Html, Main, NextScript } from 'next/document'

export default function KoalaDocument() {
  return (
    <Html>
      <Head>
        <script
          dangerouslySetInnerHTML={{
            __html: `// Paste your Koala snippet here`,
          }}
        />
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  )
}
```

## Identify visitors

Once you've installed the snippet, you can also start identifying known visitors.

```jsx theme={null}
window.ko?.identify('jane.doe@example.com', {
  name: 'Jane Doe',
  title: 'Product Manager'
})
```

Learn more about identifying visitors or setting visitor/account traits in our guide: [Identifying visitors](/docs/sdk/identify).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.