This is a Next.js template which can be deployed to Deno.
To deploy to Deno Deploy, it is recommended to build the Next.js application with "standalone" output. Once the standalone application is built, you can deploy your application to Deno Deploy by linking your GitHub repository or using the CLI.
The most convenient way to deploy your Next.js application to Deno Deploy is to link your GitHub repository to Deno Deploy. This way, your application will be automatically deployed on every commit you push to your repository. To link your GitHub repository, follow these steps:
- Fork this template (you need write permissions to the repository to link it to Deno Deploy).
- Go to https://dash.deno.com/new_project
- If it's the first time you're using Deno Deploy, you will be asked to sign up with your GitHub account.
- Search for the repository in the dropdown menu. Deno Deploy will automatically detect that you are using Next.js and prepare the necessary build configuration.
- Click "Deploy project". Deno Deploy will commit to the repository and run for
the first time a deploy.yml action that will build and deploy the application
on every push to the main branch. After that, you can customize the action
freely by editing the
.github/workflows/deploy.yml
file in your repository.
- Install
deployctl
:
deno install -gArf jsr:@deno/deployctl
- Copy the statics into the standalone output directory:
cp -r public .next/standalone/public
cp -r .next/static .next/standalone/.next/static
# Deno needs the explicit .cjs extension to interpret the file as CommonJS
mv .next/standalone/server.js .next/standalone/server.cjs
- Deploy
deployctl deploy --include=.next/standalone .next/standalone/server.cjs
For more information, see our deployment documentation.
If you've created a Next.js app using
create-next-app
,
you can deploy this to Deno Deploy right from the command line.
Since starting a Next.js server requires the command next start
, in Deno
Deploy, you can replace that command with
jsr:@deno/nextjs-start
.
To deploy your create-next-app
to Deno Deploy:
- Build your app
deno task build
- Deploy
After installing deployctl
:
deployctl deploy --include=.next --include=public jsr:@deno/nextjs-start/v15
Learn more about configuring
jsr:@deno/nextjs-start
.
To learn more about Next.js and Deno Deploy, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
- Deno Deploy - Deno Deploy documentation.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!