Private Page Subtitle
Tutorial
Building Secure Private Routes with UI Now
UI Now makes it simple to create private routes like user dashboards, account pages, and other secure sections of your SaaS application. By leveraging built-in authentication and seamless routing, you can ensure users only access what they’re authorized to.
Key Features:
Effortless Route Protection:
Thelayout.js
file in the/dashboard
directory ensures all pages and subpages under/dashboard
are private. If a user isn’t authenticated, they’ll automatically be redirected to the login page.Secure API Calls:
For making protected API requests, UI Now provides a straightforward approach. Follow the tutorial to handle authentication with ease and maintain data security.Pre-Rendered Private Data:
With server components, you can fetch user-specific data (like profiles or dashboards) securely before rendering the page. This ensures sensitive data never leaves the server unnecessarily.
Example: Creating a User Dashboard
Here’s an example of a private user dashboard that retrieves data securely:
File: /app/dashboard/page.js
How It Works:
Authentication Redirection:
Thelayout.js
file checks if the user is authenticated. If not, they’re redirected to the login page, ensuring no unauthorized access.Server Components for Data Security:
By using server components, you can fetch data like user profiles, tasks, or analytics directly from the database before rendering. This approach keeps sensitive data safe and reduces client-side overhead.Example Table (Optional):
To see the above example in action, create an SQL table calledtodos
in your database with at least one row.
Why Use UI Now for Private Routes?
Seamless Integration: Built-in tools for authentication and routing make creating private pages straightforward.
Enhanced Security: Use server-side components to fetch and display data without exposing sensitive information.
Scalable Design: Easily expand private routes to include dashboards, account settings, and more.
With UI Now, securing your SaaS application is intuitive and efficient. Ready to create your private user dashboards? Start building today.