https://github.com/rwx222/nextjs-csrf-token
Next.js and csrf tokens
https://github.com/rwx222/nextjs-csrf-token
csrf csrf-tokens edge edge-runtime middleware nextjs
Last synced: about 1 month ago
JSON representation
Next.js and csrf tokens
- Host: GitHub
- URL: https://github.com/rwx222/nextjs-csrf-token
- Owner: rwx222
- Created: 2024-08-14T02:02:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-15T20:43:03.000Z (11 months ago)
- Last Synced: 2025-07-16T18:54:43.155Z (11 months ago)
- Topics: csrf, csrf-tokens, edge, edge-runtime, middleware, nextjs
- Language: TypeScript
- Homepage:
- Size: 247 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This project is a code example where the `@edge-csrf/core` library is implemented along with `Next.js` to generate and validate `CSRF tokens`.
Important files:
- `/src/constants.ts`
- `/src/utils/csrfTokens.ts`
- `/src/middleware.ts`
- `/src/actions/deleteCsrfCookieAction.ts`
- `/src/app/api/login/route.ts`
- `/src/app/components/Login/Login.tsx`
- `/src/app/page.tsx`
## Details
👨💻 dev.to [post](https://dev.to/rwx222/csrf-tokens-in-nextjs-3mlb).
## Run the project
Install dependencies
```bash
yarn install
```
Run the development server:
```bash
yarn dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.