How to Fix: No static files in my out folder after making amendments to my site

5 min read

Your out folder is empty because next build does not generate a static export by itself. In this repo, the build completes, but nothing is written to out unless you explicitly run the static export step or configure Next.js to export during the build process.

Understanding the Root Cause

This issue happens because Next.js treats building and exporting as two different operations.

When you run next build, Next.js compiles the app and creates production artifacts inside the .next directory. That step is meant for either:

  • running the app with next start, or
  • preparing for a separate static export step.

The out directory is only created when you run next export in older setups, or when your project is configured with output: ‘export’ in newer Next.js versions. If you only run next build, you will usually see:

  • .next/ created
  • no out/ folder created

That is why the behavior in the linked repository is confusing but technically expected: the project is being built, not exported.

There is a second layer to this bug in static sites: if your app uses features that require a server at runtime, Next.js cannot fully export them as plain files. Examples include server-only logic, unsupported dynamic routes without static params, certain API routes, or components that depend on request-time rendering.

So the real root cause is usually one of these:

  1. the project runs next build but never runs the export step
  2. the project expects out to exist even though the app is configured for server output
  3. some pages are not compatible with static export

Step-by-Step Solution

The fix is to make sure the project is actually configured and executed as a static export.

1. Check the package scripts

Open package.json and inspect the scripts. If you only have a build script like this:

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start"
}

then out will not be generated automatically.

2. Add a static export flow

If the project uses a Next.js version that still supports the separate export command, add this:

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "export": "next export",
  "build:static": "next build && next export"
}

Then run:

npm run build:static

or:

yarn build:static

After that, the out folder should be generated.

3. For newer Next.js versions, configure export in next.config.js

If the project is using a newer Next.js release, use output: ‘export’ in next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'export'
}

module.exports = nextConfig

Then run:

npm run build

In this setup, Next.js will produce the static export output as part of the build flow.

4. Verify that the app is fully static-compatible

If the folder still does not contain the pages you expect, audit the code for features that break static generation. Look for:

  • getServerSideProps
  • API routes relied on by exported pages
  • request-dependent logic
  • dynamic routes missing static path generation
  • image or asset references that assume a running Node server

For example, if a page contains:

export async function getServerSideProps() {
  return {
    props: {}
  }
}

that page cannot be statically exported. Replace it with getStaticProps if the content can be generated at build time:

export async function getStaticProps() {
  return {
    props: {}
  }
}

If you have dynamic routes, make sure they also declare static paths:

export async function getStaticPaths() {
  return {
    paths: [
      { params: { slug: 'example' } }
    ],
    fallback: false
  }
}

5. Clean and rebuild

Sometimes stale artifacts make the result harder to verify. Remove old build output and run the build again:

rm -rf .next out
npm install
npm run build:static

Or, if using the newer export config:

rm -rf .next out
npm install
npm run build

6. Confirm where your assets are being emitted

After a successful export, check for:

  • out/index.html
  • out/404.html
  • out/_next/ for compiled client assets
  • copied files from public/

If you only see .next, the app was built but not exported.

7. If the repo is intended for static hosting, align deployment with export mode

If this project is meant for GitHub Pages, Netlify static hosting, or similar platforms, the deployment should point to out, not .next. That only works once static export is correctly configured.

You can also review the project source from the repository branch to compare its current scripts and config with the static export setup above.

Common Edge Cases

  • Using getServerSideProps: any page with request-time rendering cannot be exported as static HTML.
  • Dynamic routes without paths: if a route depends on params and you do not provide them at build time, export will skip or fail for those pages.
  • Client code referencing server-only APIs: code that assumes access to Node.js runtime features may work in development but break export.
  • Incorrect asset paths: static deployments often need careful handling of basePath, image references, and trailing slashes.
  • Next Image optimization: some configurations of next/image require special handling for pure static hosting.
  • API routes in the same app: exported static hosting will not run Next.js server endpoints, so front-end code must call an external API or use prebuilt data.
  • Version mismatch: older tutorials may say to use next export, while newer apps may prefer output: ‘export’. The right fix depends on the project’s Next.js version.

FAQ

Why does next build succeed if out is missing?

Because next build only compiles the application into .next. That is a valid production build for server-based deployment, so the command can succeed without creating out.

Should I deploy .next or out?

Deploy .next when running a real Next.js server. Deploy out only when the app is configured as a static export for static hosting.

What is the fastest way to fix this issue?

The fastest fix is to either add a build:static script using next build && next export, or add output: ‘export’ to next.config.js if the project uses a newer Next.js version. Then verify that no pages depend on server-side rendering.

The key takeaway is simple: an empty or missing out folder after next build is usually not a failed build. It means the project has not completed the static export step, or parts of the app are not compatible with static output yet.

Leave a Reply

Your email address will not be published. Required fields are marked *