Running Locally

Build the app, start the dev server, and confirm it loads in the browser.

Last updated:

Step 3: Set up the database

With the environment variables configured, the next step is to create the database schema and populate the initial data. At this stage, the process is straightforward: run the Prisma migration command against your target database so Prisma can create the tables, relations, and other schema objects defined by your project.

Go to the terminal and run the command below:

bash
npx prisma migrate dev --name init
Running Prisma migration

If the local generation of the initial migration is successful, you should see this message: "Your database is now in sync with your schema."

To apply all pending migrations in the target environment, run the command:

bash
npx prisma migrate deploy

Go back to the Neon project's page and refresh the Tables dashboard. You should now see all the tables.

Neon Tables dashboard

Cool. The next step is to populate the database with pre-created content. In the terminal, run the db seed command:

bash
npx prisma db seed
Running Prisma database seed command

Confirm the success message in the DB seed command. If yes, check if the remote database is populated properly.

Populated remote database in Neon

Awesome! The database is finally done. The next step is to build and run the project locally.

Build and run the project

After the database is set up, the next step is to build the project. This creates an optimized production-ready version of the application that can be deployed to your server or hosting platform.

Run the build command from the root of the project:

bash
npm run build
npm run build command output

During this step, the framework compiles the application, checks for build-time issues, and generates the output needed for production. If the build completes successfully, your project is ready for the final deployment steps, such as starting the server or publishing the generated files.

This step is a useful checkpoint because it confirms that the application, configuration, and dependencies are all in a deployable state.

Start the development server so you can preview the project locally:

bash
npm run dev
Start Next.js development server

Now, open http://localhost:3000 in a browser, and the BloggFast dashboard looks like the image below. You should also see this list of articles.

BloggFast dashboard running locally in the browser

Toggle the theme to see if the dark mode works correctly.

BloggFast dashboard in dark mode

This is what the article preview looks like:

Article preview page

Alright, everything looks good. It's time to test the auth and article generation.

Available npm scripts

ScriptWhat it does
npm run devStarts the Next.js dev server at http://localhost:3000
npm run buildRuns prisma generate then builds for production
npm run startServes the production build
npm run lintRuns ESLint
npm run db:generateprisma generate
npm run db:migrateprisma migrate dev
npm run db:pushprisma db push
npm run db:seednpx tsx prisma/seed.ts
npm run db:studioPrisma Studio at http://localhost:5555