Skip to content

An example Next.js project exported as a static HTML, CSS, and JavaScript application.

Notifications You must be signed in to change notification settings

Globacore/static-export-example

Repository files navigation

Static Export Example

This is a Next.js 13 application that will export a static HTML + CSS + JavaScript application.

Setup

Install dependencies:

npm install

Running locally:

npm run dev

Open your browser to http://localhost:3000.

Configuring production subpath

In production, the application should be served under a subpath as opposed to the root of the production domain.

Edit next.config.js to configure the subpath under which the application should be served in production.

/** @type {import('next').NextConfig} */
const nextConfig = {
  output: "export",
  // replace "/subpath" with the desired path for the production environment
  basePath: process.env.NODE_ENV === "production" ? "/subpath" : "",
}

module.exports = nextConfig

Building for production

Run the npm build script.

npm run build

This will generate a completely static build to the ./out folder that can be served by any typical web server.

About

An example Next.js project exported as a static HTML, CSS, and JavaScript application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published