It took me a week to figure out how to add Sequelize to my Next JS app so I wanted to share my approach so others can steal the pattern as well as welcome feedback.
The commit history is well documented in sections of the project
- Create a
.env
file with the following values
// .env
DB_HOST=localhost
DB_USERNAME=root
DB_PASSWORD=
DB_NAME=ts_next_sequelize_example
DB_PORT=5432
- Run the following commands
# Install node packages
$ npm install
# Create the database
$ npm run db:create
# Run the migrations that will create the tables
$ npm run db:migrate
# Run the seed
$ npm run db:seed
- Run the command
$ npm run dev
- Visit http://localhost:3000