Next.js

From David's Wiki
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Next.js allows you to deploy web applications with dynamic server-side and client-side rendering. It also supports static site generation which allows you to build a website and serve it from a file server of your choice.

Static HTML Export

Reference: https://nextjs.org/docs/advanced-features/static-html-export

With a static export, you can serve your website using any file server which can rewrite paths to html files. For example, in Caddy the following config would suffice:

davidl.me {
  root * /var/www/davidl_me/out
  try_files {path} {path}.html
  file_server
}

If you have folders with the same names as pages, you may want to remove trailing slashes:

# Using a redirect
@pathWithSlash path_regexp dir ^(.*)/$
redir @pathWithSlash {re.dir.1}
# Using a rewrite
uri strip_suffix /