Base Path
To deploy a Next.js application under a sub-path of a domain you can use the basePath
config option.
basePath
allows you to set a path prefix for the application. For example, to use /docs
instead of /
(the default), open next.config.js
and add the config:
When linking to other pages using next/link
and next/router
the basePath
will be automatically applied.
For example, using /about
will automatically become /docs/about
when is set to /docs
.
This makes sure that you don’t have to change all links in your application when changing the basePath
value.
Images
When using the component, you will need to add the basePath
in front of src
.