Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Next.js learn but using Postgres.js instead of @vercel/postgres

License

NotificationsYou must be signed in to change notification settings

masfahru/nextjs-dashboard-example-with-authentication

Repository files navigation

This is a modified result after followingNext.js learning course

Tech-stack:

Requirements

  • Nodejs v20
  • Package Manager (npm, yarn, or bun)
  • PostgreSQL server (if you want to use local database server)

Development

  • Clone this project to local
  • Install dependencies:npm i
  • Copy .env.example to .env
  • Modify .env as per the requirement
  • Run database seed (just for once):npm run seed
  • runnpm run dev

Build

  • runnpm run build

Start

  • runnpm run start after successful build.

The changes

There are some differences between the original result of the course and this repository, which are:

Database driver

UsingPostgres.js instead of@vercel/postgres, both of them have a similiar syntax.

for example:

const[result]=sql``;

Authentication

Implement a simple session manager, so we can force log-out other sessions by deleting their session id from the database.

Credentials:

{"email":"user@nextmail.com","password":"123456"}

Web Endpoints

  • Signinhttp://localhost:3000/login
  • Dashboardhttp://localhost:3000/dashboard

RestAPI Endpoints

Signin POSThttp://localhost:3000/api/auth/callback/credentials

payload:

{"email":"user@nextmail.com","password":"123456","callbackUrl":"/api/auth/session"}

callbackUrl can be changed to any pathname to redirect after successful sign-in

Signout POSThttp://localhost:3000/api/auth/signout

payload:

{"callbackUrl":"/api/auth/providers"}

callbackUrl can be changed to any pathname to redirect after successful sign-out

About

Next.js learn but using Postgres.js instead of @vercel/postgres

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp