> For the complete documentation index, see [llms.txt](https://docs.mosaic.js.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mosaic.js.org/getting-started/nextjs.md).

# Next.js

#### Install the dependencies

Using mosaic requires two packages in your Next.js project - the start script package and the runtime package.

{% tabs %}
{% tab title="yarn" %}

```javascript
yarn add @tilework/mosaic-nextjs-scripts @tilework/mosaic
```

{% endtab %}

{% tab title="npm" %}

```javascript
npm install @tilework/mosaic-nextjs-scripts @tilework/mosaic
```

{% endtab %}
{% endtabs %}

#### Use the new scripts

Replace `next` invocations in the `scripts` block of your package.json. Such way, Next.js will be launched with additional configurations (Webpack and Babel) required for Mosaic.

{% code title="package.json" %}

```diff
{
    "scripts": {
-        "dev": "next",
+        "dev": "nextjs-scripts dev",
-        "build": "next build",
+        "build": "nextjs-scripts build",
-        "start": "next start",
+        "start": "nextjs-scripts start",
               
+        "link": "nextjs-scripts link",
+        "test": "nextjs-scripts test"  
    }
}
```

{% endcode %}

#### Clean up

`next` is a dependency of `mosaic-nextjs-scripts`, thus is no longer needed in your project as a direct dependency. It is advised to remove this redundant dependency.

{% tabs %}
{% tab title="yarn" %}

```diff
yarn remove next
```

{% endtab %}

{% tab title="npm" %}

```diff
npm uninstall next
```

{% endtab %}
{% endtabs %}

&#x20;
