# Next.js





Sample.app serves static files only. To deploy a Next.js project, you need to enable static export.

<Callout type="warn">
  Static export doesn't support server-side rendering, API routes, middleware, or image
  optimization. See the [Next.js static export
  docs](https://nextjs.org/docs/app/building-your-application/deploying/static-exports) for full
  details.
</Callout>

Deploy [#deploy]

<Steps>
  <Step>
    Configure static export [#configure-static-export]

    Add `output: 'export'` to your Next.js config:

    ```js title="next.config.js"
    /** @type {import('next').NextConfig} */
    const nextConfig = {
      output: "export",
    };

    module.exports = nextConfig;
    ```
  </Step>

  <Step>
    Build your project [#build-your-project]

    ```bash
    npm run build
    ```

    This outputs to `out/` by default.
  </Step>

  <Step>
    Deploy to Sample.app [#deploy-to-sampleapp]

    ```bash
    samplex deploy ./out
    ```
  </Step>
</Steps>

Image optimization [#image-optimization]

Next.js image optimization requires a server, which isn't available with static export. Add this to your config:

```js title="next.config.js"
const nextConfig = {
  output: "export",
  images: {
    unoptimized: true,
  },
};
```

<Callout type="info">
  Consider using a third-party image CDN or pre-optimizing images at build time as an alternative.
</Callout>
