Home > Software engineering >  Deploying NextJs ExpressJs postgreSQL (pgadmin)
Deploying NextJs ExpressJs postgreSQL (pgadmin)

Time:10-15

Here is the scenario: I have NextJs app ready to go, I have ExpressJs Server ready to go, I have postgreSQL (pgAdmin) ready to go.

Can I or should I?

Deploy Next to Vercel, get a domain from GoDaddy (for example) and link it to project. Deploy both express and database to heroku.

I don’t know if I can do all of them on Vercel.

CodePudding user response:

Yes, you can do stuff you need with Vercel. Check this examples(express, mysql) of code, adapt it for your needs.

So, to deploy

  1. Set up your project with ExpressJs NextJs and postgreSQL. (ofc using github repo for next steps). You can just git clone repository of express example, modify it git push to your github account.
  2. All environment variables you declare in your .env folder !very important!, and checking your .env files are ignored by git (.gitignore file). This check is very important because you never expose .env files and connection string at git)
  3. Once the local project works, you following step 4
  4. You set up your vertical environment - linking github repository, setting up vercel settings you need. (for example, you can directly rent a domain name and set up it for production environment)
  5. After, you are setting up env variables of vercel, with the same variable name and values (for example, your DB connection string, but NOT your base_url of course), you deploy your project with vercel.
  6. Every time you git push your project, vercel will redeploy your online project and update all pages. It's really great.

What I suggest to you:

  • you create very simple project with your needs(you mentionned) and try to deploy it. In case of errors, you can google, it will not be so hard. Once a simple project works, you start to develop it.
  • use mostly NextJS hooks and code (not react), read the documentation. For example, instead of using useEffect(react) you use useSWR(react lib created by vercel and nextjs teams) hook for data fetching, so you will develop much more faster and "clean")
  • try to use Typescript if possible (but JS is also great)
  • take your time and try to avoid pure react code (CTRL C CTRL V) from react projects.
  • "fight" errors and check the console warnings from the beginning.
  • if you like to have some video tutorials, you can check this (but it is js and not ts.)
  • if you project will use multilanguage in future, set up all envirnoment and test it in the begginning. In this case also set up i18n lib for future translations
  • the hardest and important part is set up, test all your libs before you start "real" coding.

I am sure you will enjoy!

P.S. for the pgsql and express you will need to construct your API routes,

  • Related