Crema React
v-1
v-1
  • About Crema(CRA)
  • Product Overview
  • Folder Structure
  • Installation
    • Pre-Requisites
    • Installing Crema
  • Default Route
  • Customization
    • Template Style
    • Template Mode
    • Template and Sidebar Color
    • Tempate Direction
    • Navigation Style
    • Footer
    • Footer Type
    • Route Transition
  • Multi-Lingual Support
    • Changing Language
    • Adding New Language
  • Sidebar Menu
    • Adding New Menu
  • Route Protection
  • Loggedin User
  • Axios Setup
  • Package.json
  • GitHub Access
  • Slack Community
  • FAQ
  • CRA-SSR
    • About CRA+SSR
    • Installation
    • Folder Structure
    • Route Protection
    • Deploy to server
  • Next.js
    • About Next.JS
    • Installation
    • Folder Structure
    • Deploy to server
  • Next.Js + TypeScript
    • About Next.js + Typescript
    • Installation
    • Folder Structure
    • Deploy to server
  • CRA + TypeScript
    • About CRA + TypeScript
  • Tailwind CSS
    • About Tailwind CSS
  • Styled Component
    • About Styled Component
  • Servers
    • Python
    • Mongoose
    • Laravel
Powered by GitBook
On this page

Was this helpful?

Route Protection

Last updated 5 years ago

Was this helpful?

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 loggedin 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:-

Go to the file, where the routes have been declared. For example, let's go to the dashboard file where the dashboard related routes have been declared, the file can be found at:-

src/modules/dashboard/index.js

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

If this 'auth' property is added, this route will be protected and requires a loggedin user to access this path and if this property is not passed, then this path is directly accessible without any condition.