learn-auth-redirect-nextjs icon indicating copy to clipboard operation
learn-auth-redirect-nextjs copied to clipboard

Learning auth redirect on Next.js to prevent content flashing

Learn Auth Redirect Nextjs

This is a NextJs and Tailwind project bootstrapped using nextjs-tailwind-starter created by Theodorus Clarence.

Log

  • [x] redirect when is not logged in (works if you directly open /blocked)
  • [x] don't show content when waiting to check if logged in (fixed with full page loader)
  • [ ] when going to page /blocked using button, still flashes full page loader for a split second

Getting Started

To use this starter, you can use create-next-app to do it by:

npx create-next-app -e https://github.com/theodorusclarence/nextjs-tailwind-starter project-name

or

Deploy with Vercel

First, run the development server:

npm run dev
# or
yarn dev

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

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file