Next.js Discord

Discord Forum

Deployment out of vercel cloud is that complicated?

Unanswered
Atlantic herring posted this in #help-forum
Open in Discord
Atlantic herringOP
It seems that a Next project required more work if deployed on own servers or aws, g-cloud or azure isn't it?
I am starting with Next.js deployment to production environment.

24 Replies

Scottish Fold
I spent hours today researching different hosting for Nextjs and everything i could find was that you're pretty much stuck with Vercel
I guess makes sense that they built nextjs that way
I'm okay with paying money obviously but not ridiculously if i'm just a one man project
@Scottish Fold This is not the case in the slightest
I've deployed, with fairly minimal effort, Next.js apps on GCP, AWS, on a VPS with Coolify, and on a VPS standalone
Scottish Fold
With all the parts working? I read that S3 doesn't support SSR
Their provided self hosting docker image has worked quite well for me in almost every case. There are a few things to consider that Vercel automatically takes care of, but generally speaking it's a breeze
Scottish Fold
Do you happen to have any resources i could look at.
?
Directly from the [Next.js docs](https://nextjs.org/docs/app/building-your-application/deploying#docker-image):

Next.js can be deployed to any hosting provider that supports Docker containers.

Next.js through Docker supports all Next.js features.
I can't speak as much to platform specific stuff, as our company mainly uses GCP as opposed to AWS
But on GCP, we host Next.js using essentially their provided Docker image on Cloud Run
And every feature (and we're pretty bleeding edge on a couple apps, React 19, Next 15, etc) that we've explored works fantastic, especially SSR
Let me know if you have any questions 🫡 I'd love to help out, self hosting Next.js apps is definitely right up my alley lol
@riský > Next.js through Docker supports all Next.js features. i mean kinda... however things like edge ofc wont work and other things that are really vercely
We use middleware on a few Next 14 app router apps, on GCP, isn't that technically the "edge" runtime?
i mean it uses the annoying restricted env, but its not the actual edge (like cf workers and what vercel does)
Ah, yeah fair enough, we did have to stop using the fs module when we switched over. I was always wondering about that nuance and what "edge" was in the context of GCP
On the topic of asterisks on self hosting next.js, there are a couple other considerations, the first two only really apply to horizontally scaled setups though:

1. You need to (and this is buried in the docs) set a NEXT_SERVER_ACTIONS_ENCRYPTION_KEY env variable so that all of your instances parse encrypted server actions the same way.

2. By default, all of Next.js route caching, and caching in general is in memory/filesystem. The problem with that is on Vercel, it's smart and automatically handles that. On any other horizontally scaled setup, each instance of your app will have it's own app cache. Not really a huge deal depending on the type of app you're making, but if that's an issue, you'll need to use a custom cache handler. At our company we recently started using [next-shared-cache](https://caching-tools.github.io/next-shared-cache) and it's been great.

3. I would highly recommend setting up [generateBuildId](https://nextjs.org/docs/app/api-reference/next-config-js/generateBuildId) and [deploymentId](https://nextjs.org/docs/app/building-your-application/deploying#version-skew) on your next config to help with version skew across deployments. (we use our git commit short sha1)

4. And lastly, you may want to disable buffering if you're using Nginx or a similar proxy. Typically in most setups this can be done by copying their [example here](https://nextjs.org/docs/app/building-your-application/deploying#streaming-and-suspense).
I should say, that although this seems like a lot, at our company we didn't do #2, #3, or #4 for quite awhile, and they didn't exactly make groundbreaking changes in the peformance, devx, or UX of our apps, honestly pretty unnoticable, but, if you want to try to get as close to Vercel support/performance, those steps will definitely get you there.
@Luke Let me know if you have any questions 🫡 I'd love to help out, self hosting Next.js apps is definitely right up my alley lol
Scottish Fold
do you have any knowledge about Flexstack? I'm reading this article and i've googled a bit. It seems like Flexstack is kind of like Vercel, where they're selling their UI for AWS but looking at their pricing (https://flexstack.com/pricing) it seems that they have just fixed price for the interface rather than prices spiraling exponentially. (Note that i don't have experience with deployments on any cloud platform like AWS or GCP) so tool like these are fine if they make deployment for me very easy.
https://flexstack.com/docs/languages-and-frameworks/how-to-deploy-next-js-to-aws
i also saw many people commenting about SST but i don't know about that either
https://docs.sst.dev/start/nextjs
also i'm fine with using/paying for services for now if that means i don't have to sink in a lot of time to learn the inner workings of AWS or something (if needed in the future, should my app become more popular, i can sink in the time then)