Join our Newsletter — 33% off our NHI Course
Home› FAQ› Architecture & Implementation› How should teams protect routes in a native…
Architecture & Implementation

How should teams protect routes in a native Expo app without breaking public screens?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated October 22, 2026 Domain: Architecture & Implementation

Put the session check in the route group layout, not inside each screen, and let public routes remain public. That keeps the app responsive while making protected content inherit the same auth decision. Always wait for the loaded state before redirecting, and keep server-side verification in place for any sensitive data or action.

Why route protection belongs in the layout, not inside each screen

In a native Expo app, route protection works best when the access decision is made once at the route group level and then inherited by the screens under that group. That keeps the app from re-running the same guard logic on every screen mount, and it avoids the common mistake of mixing navigation logic with page rendering logic.

For public screens, the important principle is separation: public routes should render immediately, while protected routes should only mount after the session state is known. That gives you a clean public surface without forcing the whole app through an authentication gate that slows first paint or creates confusing redirects.

When teams put the check inside each screen, they often create inconsistent behavior. A screen can briefly render, redirect late, or flash protected UI before the redirect completes. A layout-level decision reduces that churn because the route group can evaluate the session once and apply the same outcome to every child route.

How to handle loading state and redirects without breaking UX

The key implementation detail is to wait for the loaded state before redirecting. Until the session check has finished, the app does not yet know whether the user is signed in, signed out, or still being restored from storage. Redirecting too early turns an ordinary loading phase into a false access denial.

That waiting period is especially important in mobile apps where session hydration may depend on async storage, native startup timing, or network-backed validation. If the app redirects before the session is resolved, a user may be bounced away from a protected area and then sent back again moments later, which feels broken even when the auth logic is technically correct.

The practical pattern is simple: treat the layout as the gate, keep the public routes outside that gate, and let the protected subtree render only after the session has settled. The screen itself should focus on its own UI state, not on deciding whether navigation is allowed.

Why server-side verification still matters for sensitive actions and data

Client-side route protection is useful for user experience and basic navigation control, but it is not a security boundary on its own. Any sensitive data or action must still be verified on the server, because route logic only decides what the app shows, not what an attacker can request directly.

That distinction matters whenever the protected screen fetches private records, submits state-changing requests, or exposes high-value account operations. A well-structured route tree can prevent casual exposure in the app shell, but the backend must still enforce the real access decision for every protected operation.

In practice, the route layer and the server layer should agree but serve different purposes. The route layer protects the user journey and keeps public screens usable. The server layer protects the underlying resource and remains the final authority for authorization.

Risk and Threat Considerations

Route guards that run too late, or on every screen instead of in the layout, can create UI flicker, inconsistent authorization decisions, and accidental exposure of protected content in the client shell. The bigger risk is assuming the frontend decision is a control boundary when it is only a navigation and experience control.

Failure mechanism: If session state is unresolved when a redirect decision is made, the app can misclassify the user, interrupt public navigation, or briefly render content that should have stayed hidden. If the backend does not re-check access, a direct request can still reach protected data or actions even when the screen itself was blocked.

Impact: Users experience broken navigation and trust the app less, while attackers can bypass client-side routing by calling the underlying API or service directly. The result is exposure of sensitive data, unauthorized actions, or a false sense of security around public and protected route separation.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while NIST CSF 2.0, NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST CSF 2.0PR.AA-05 — Identity Management, Authentication, and Access ControlRoute gating depends on authenticating users before protected access is granted.
Recommendation — Apply PR.AA-05 to require authenticated access before protected routes expose sensitive content.
NIST SP 800-53 Rev 5AC-6 — Least PrivilegePublic and protected routes should not expose more than a user is entitled to access.
Recommendation — Apply AC-6 to limit route-linked access to only the permissions each user needs.
OWASP ASVSV8 — AuthorizationProtected screens must still be backed by server-side authorization, not UI-only checks.
Recommendation — Use V8 to enforce authorization on every protected action and resource request.
OWASP API Security Top 10API5 — Broken Function Level AuthorizationClient-side route checks do not stop unauthorized access to privileged backend functions.
Recommendation — Test for API5 by validating that protected functions reject callers lacking the required role or scope.
CIS Controls v8CIS-6 — Access Control ManagementThe pattern relies on separating public access from protected access paths.
Recommendation — Use CIS-6 to manage who can reach protected screens, data, and actions.

Practitioner Guidance

What to verify: Confirm that the layout only makes a redirect decision after the session state is loaded, and that public routes render without inheriting protected-route checks. Then verify that protected API calls still fail closed when made outside the app path.

Decision rule: If the user’s access state is not yet known, show the loading state and do not redirect. If the session is known and invalid, redirect once at the layout boundary rather than repeating the check in every screen.

Common mistake: Do not treat “the screen is hidden” as equivalent to “the data is protected.” The route tree should control navigation, while the backend must control access to anything sensitive.

Practitioner takeaway: The cleanest Expo auth pattern is to centralize route decisions at the group layout, keep public screens truly public, and rely on server enforcement for the real security boundary.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 22, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org