Blog

April 17, 2025

Create password protected pages

Selene YuSelene Yu

Add protected pages

To enable password protection for specific pages, add the page paths you want to protect to the protectedRoutes object in the resources/config.js file.

The RouteGuard component will automatically handle access control for these pages, requiring password authentication before allowing access.

Tsx
const protectedRoutes = {
  '/work/once-ui': true
};

The code above will ensure that the /work/once-ui page is only accessible after providing a password.

Set a password

The password can be set in the .env.local file for local development and as an environment variable for production.

Share this post: