Deploying Strapi + NextJS on DigitalOcean App Platform (with NextAuth)
Deploying an app sounds easy, but it’s not always straight forward! This tutorial will go through step by step, everything you need to deploy a Strapi.js + Next.js application on DigitalOcean App Platform.
This guide assumes you already have a Next.js and Strapi running in development, and you just want to deploy it. You’ll see:
- How to deploy a Strapi Backend to DO App Platform
- Deploy your Next.JS front end to DO app platform
- Set up Next.JS Auth with DigitalOcean
Why DigitalOcean App Platform for Strapi?
Strapi comes with tonnes of ways to deploy your app - just check their for excellent and detailed guides for all of these:
The problem for me is that these guides are stupidly long, and sometimes I’m a bit out of my depth with it.
Most options, such as the one-click digital ocean droplets make hosting Strapi really affordable - you can use $10 a month and host the lot! But the real price is time. You’ll have to figure out:
- how to connect it to your GitHub and configure continuous deployment
- how to get all your locally seeded data into the PostgreSQL database
- how to change it from a strapi development instance to production
- how to set up an SSL certificate
It’s a lot! Then you have to maintain the server on top of all of this. Scaling the app, and managing your own database is a big job!
DigitalOcean App Platform
That’s where services like DO App Platform and Heroku come in handy. I opted for DO, but here are comparisons between DO and Heroku:
Setting it up
The most useful resources:
Strapi Headless CMS & Gatsby
The FASTEST, EASIEST way to get going as of January 2021
Strapi Headless CMS & Gatsby • medium.com
Following the YouTube video is the best way. Things I noticed:
1. Deploying the Backend Strapi App
If you have an app already set up, following the video above, you’ll notice there’s only 2 things you need to add. Those are database.js, and a server.js file. Both go inside /config/env/production/.
Create the folder, /config/env/production/ and add add a database.js file. Inside it, add this: