Files
vercel__next.js/errors/api-routes-static-export.mdx
Delba de Oliveira 2e2ee08b60 Docs IA 2.0: Delete routing section, add BFF guide, polish getting started (#80365)
Closes:
https://linear.app/vercel/issue/DOC-4686/clean-up-routing-section
Redirects: https://github.com/vercel/front/pull/47151

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-06-16 13:42:20 +01:00

24 lines
1.9 KiB
Plaintext

---
title: Understanding "API Routes in Static Export" Warning in Next.js
description: This document explains the "API Routes in Static Export" warning in Next.js and offers steps to resolve it.
---
## Why This Warning Occurred
The "API Routes in Static Export" warning is typically raised when an `exportPathMap` path is matched to an API route while trying to statically export a Next.js application via the `next export` command. This command disables API routes as it is designed for a static-only setup.
Running `next export` is not necessary to make your application static. Pages in your application that do not have server-side data dependencies will be automatically statically optimized when you run `next build`. This includes pages powered by `getStaticProps`.
## Possible Ways to Fix It
To resolve this issue, you have two main options:
1. Use the `next build` command instead of `next export` if you're deploying your application on platforms that don't require `next export`. For example, [Vercel](https://vercel.com) is a popular hosting platform for Next.js applications that supports this feature.
2. If you still need to use `next export`, make sure to remove any paths that use API routes from your `exportPathMap` in your `next.config.js` file.
3. Consider [incrementally adopting the App Router](/docs/app/guides/migrating/app-router-migration), which supports [Route Handlers](/docs/app/api-reference/file-conventions/route). These "API Routes" can be used to create endpoints that can be statically exported in your application.
## Useful Links
- [Static HTML export](/docs/pages/guides/static-exports) - Learn more about how you can create a static HTML export of your Next.js application.
- [Route Handlers](/docs/app/api-reference/file-conventions/route) - Learn more about how you can use Route Handlers to create endpoints that can be statically exported in your application.