> For the complete documentation index, see [llms.txt](https://docs.cremawork.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cremawork.com/v2.0/route-protection.md).

# Route Protection

Route protection means protecting any defined path from unauthorized access. For example, Signin or Signup pages are common paths/unrestricted paths and any user can access it. However there are many paths or pages that only logged in users can access, those paths are called Protected Routes. In Crema, we have provided the functionality of route protection, you have to follow the following steps to protect the route:-\
\
**Step 1.** To hide/show the menu based on the **user role**, We need to protect the navigation menu as well as routes. To protect the navigation menu go to the **src/modules/routesConfig.js** file, In this file, we declared all the navigation(route) menu. We want to bind the menu with the auth role of the user. then we assign the role to the route menu.

While defining the route menu, you have to pass one extra property named "**auth**" in the menu object in order to make the menu protected like below.

![](/files/-MKjLRsU4FXL6Dm4X3Hm)

**Step 2.** We need to protect the route from unwanted access. To protect the route from unwanted access,  we need to add the '**auth**' property, this route will be protected and need particular role access to access it and if this property is not passed, then this path is directly accessible without any condition.

```
src/modules/dashboard/index.js
```

While declaring the route, you have to pass one extra property named "auth" in the route object in order to make the route protected.

![](/files/-MKjPkkU5P_kXEXThl7d)

If this '**auth**' property is added, this route will be protected and requires a logged-in user to access this path and fulfill the required **role** and if this property is not passed, then this path is directly accessible without any condition.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cremawork.com/v2.0/route-protection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
