> For the complete documentation index, see [llms.txt](https://docs.squidrouter.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.squidrouter.com/old-v2-documentation-deprecated/add-a-widget/widget/nextjs-installation.md).

# NextJS Installation

Integrating the widget into a NextJS app

Our full NextJS example can be found [here](https://github.com/0xsquid/widget-integrations/tree/main/packages/next-app).

First, get everything set up as outlined in [Installing the Widget](/old-v2-documentation-deprecated/add-a-widget/widget/installing-the-widget.md).

### Transpile module

Adding the widget in NextJS requires adding the transpile module package. This plugin aims to solve the following challenges:

* code transpilation from local packages (think: a monorepo with a `styleguide` package)
* code transpilation from NPM modules using ES6 imports (e.g `lodash-es`)

#### NextJS >=13.1

If you are using NextJS 13.1 or newer, the `next-transpile-modules` package comes built-in in NextJS, so you just need to add the following in your `next.config.js`:

```javascript
const nextConfig = {
  transpilePackages: ["@0xsquid/widget"]
}

module.exports = nextConfig
```

#### NextJS <13.1

If you are using a NextJS version older than 13.1, then you need to install the `next-transpile-modules` package.

Transpile module installation:

```bash
npm i next-transpile-modules
```

or

```
yarn add next-transpile-modules
```

\
Following this, on the `next.config.js` file, add the following to import the widget as a transpiled module:

```javascript
const withTM = require("next-transpile-modules")(["@0xsquid/widget"]);

const nextConfig = {
  // Your nextjs config
};

module.exports = withTM(nextConfig);
```

Finally, install and configure the widget, as specified in [React Installation](/old-v2-documentation-deprecated/add-a-widget/widget/react-installation.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.squidrouter.com/old-v2-documentation-deprecated/add-a-widget/widget/nextjs-installation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
