You can protect specific routes in your documentation by adding the protectedRoutes property to
your Dev Portal configuration. This property supports two formats: a simple array of
path patterns, or an advanced object format with custom authorization logic.
Array Format
The simplest way to protect routes is to provide an array of path patterns. Users must be authenticated to access these routes.
zudoku.config.ts
Advanced Object Format
For more complex authorization logic, you can provide a record mapping route patterns to custom callback functions:
zudoku.config.ts
The callback function receives an object with:
auth: The current authentication state includingisAuthenticated,userdata, and morecontext: The Dev Portal context providing access to configuration and utilities
The callback must return a boolean indicating whether the user should have access to the route.
Path Patterns
The path patterns follow the same syntax as React Router:
:parammatches a URL segment up to the next/,?, or#*matches zero or more characters up to the next/,?, or#/*matches all characters after the pattern
For example:
/users/:idmatches/users/123or/users/abc/docs/*matches/docs/getting-startedor/docs/api/reference/settingsmatches only the exact path/settings
After logging in, users will be automatically redirected back to the protected route they were trying to access.
Next Steps
- Learn about authentication providers supported by Dev Portal - Configure user data display