Deploy a nextjs app to railway??
I've been thinking about using railway to host my nextjs app with api routes, serverless functions and image. Vercel seems a little pricey when it comes to scaling. does railway provide all the features that vercel does when hosting a next app?
9 Replies
Project ID:
N/A
N/A
I switched my nextjs app from vercel to railway without problems, here is my setup
- 1 project 3 services on railway 1 postgresql, 1 nextjs app, 1 db backup script on cronjob -> cost of this is around $1.5/m for me traffic is around 200 people a day.
- using cloudflare r2, images, dns, proxy, cdn, cache, mail forwarding analytics (its all free, images is $5/m)
- you can continue using Image component from nextjs but better to host all images on cloudflare to reduce egress and for faster delivery
- remember to use private database url to connect your app to your db to reduce egress
- disable image optimization with flags and remove sharp library -> which would reduce your ram usage 3x (nextjs keeps images in memory if you don't so, there is an open github issue on their side)
Another option I'm still experimenting with is flightcontrol as I've received some aws credits ($1000/2years) but its definately is 5-10x more expensive when you are out of credits say 2 years later.
hey oreo, i have to thank for your time, i will surely follow everything you said. im still fresh to the production scene, i have one more question tho, cuz i heard people saying something about api routes not working as expected. with railway the api routes also work correctly right?
other than that i really appreciate your help!
yeap my app uses app router, api routes, server components and server actions without any problems you can see the whole stack at https://nextedgestarter.com
oh i thought i could hook up railway directly to my next app repo on github 😅
so i need a service for this?
no its just a boilerplate I've built, shared for you to see what works in that stack on railway (everything)
Oreo this is amazing advice!!
i really appreciate you man!
thanks for all the help