Permission Checking Fundamentals
You'll learn where to perform permission checks in your frontend application to properly control feature access.
The Core Idea
Permission checking in the frontend is about when and where you evaluate whether a user can access a feature. Unlike role checking (which asks "is the user an admin?"), permission checking asks "can this user perform this specific action on this specific resource?"
Think of it like a bouncer at a VIP club. They don't just check if you're a "VIP" (role). They check if you're on the list for tonight's event (permission), if you're allowed in this section (resource), and if you can bring guests (action).
When to Check Permissions
Perform permission checks at multiple UI layers:
- Route level – Before rendering entire pages
- Component mount – When a component first loads
- Before user actions – When deciding to show/enable buttons
- After data loads – When resource-specific permissions arrive from the API
Where to Check Permissions
Unlike roles (which you might store in a token), permissions often come from the backend with the resource itself. For example, an API might return:
{
"document": {...},
"permissions": {
"canEdit": true,
"canDelete": false,
"canShare": true
}
}
Check these permissions in your render logic, event handlers, and routing guards—wherever access decisions happen.
The Timing Challenge
Permission checks must happen after authentication but before rendering protected content. You'll often show loading states while waiting for permission data from the server.
Key Takeaway: Permission checking happens at multiple UI layers and often depends on server-provided data about what actions the current user can perform on specific resources, not just their role.