Skip to content

andresdotsh/nextjs-csrf-token

Repository files navigation

This project is a code example where the @edge-csrf/core library is implemented along with Next.js 14 to generate and validate CSRF tokens.

Important files:

  • /src/constants.js
  • /src/middleware.js
  • /src/app/page.js
  • /src/app/components/Login/Login.js
  • /src/app/api/login/route.js
  • /src/utils/csrfTokens.js
  • /src/actions/deleteCsrfCookieAction.js

Run the project

This is a Next.js 14 project bootstrapped with yarn create next-app.

Install dependencies

yarn install

Run the development server:

yarn dev

Open http://localhost:3000 with your browser to see the result.