---
url: https://paperpic.dev/reference/nuxt.md
description: >-
  How the PaperPic module for Nuxt 4 sets up the Vue component and its
  stylesheet, so your templates use the viewer without importing anything.
---

# Nuxt

`@paperpic/nuxt` is the module for Nuxt 4. It registers the `PaperPic` component of [`@paperpic/vue`](./vue) and adds its stylesheet to your app, so your templates can use the viewer without importing anything.

## Installation

::: code-group

```sh [npm]
npm install @paperpic/nuxt
```

```sh [pnpm]
pnpm add @paperpic/nuxt
```

```sh [yarn]
yarn add @paperpic/nuxt
```

```sh [bun]
bun add @paperpic/nuxt
```

:::

Then add the module to `nuxt.config.ts`:

```ts
export default defineNuxtConfig({
  modules: ['@paperpic/nuxt'],
})
```

`@paperpic/vue` comes with the module, so you do not need to install it yourself.

## Usage

```vue
<script setup lang="ts">
import type { ExportedImage } from '@paperpic/nuxt'

function upload({ blob }: ExportedImage) {
  // Send the edited image to your server
}
</script>

<template>
  <div style="height: 480px">
    <PaperPic src="/receipt.jpg" alt="A receipt" @apply="upload" />
  </div>
</template>
```

The component fills its parent element, so give the parent a height. It is the same component that `@paperpic/vue` exports, so the [Vue](./vue) page describes its props, events and methods.

The Vue examples in these docs work in Nuxt too. Leave out the lines that import the component and `style.css` from `@paperpic/vue`, and import the types from `@paperpic/nuxt` instead. Tests change a little too, as the [Testing](../guide/testing#nuxt) page shows.

## Lazy loading {#lazy}

Nuxt also registers the component as `<LazyPaperPic>`, which downloads the code of the viewer only when it first renders, for example when the user opens a dialog. A page that does not show the viewer right away then loads less code. The stylesheet is part of the app, so it is already there when the viewer appears.

## Types {#types}

`@paperpic/nuxt` exports every type of `@paperpic/vue`, so import your types from it, such as `import type { PaperPicInstance } from '@paperpic/nuxt'`. The [Types](./types) page shows what each one holds.

## Server-side rendering

The component renders an empty element on the server and creates the viewer in the browser when it mounts, so you do not need to wrap it in `<ClientOnly>`.

## Options

The module has no options of its own yet. You set up each viewer with the props of the component, as in Vue.
