Guards


Introduction

Guards can be used to protect private or public routes based on the current user role.

Auth Guard

The AuthGuard component can be used to protect a private route from unauthenticated users.
import AuthGuard from "../components/guards/AuthGuard";
        
function Component() {
  return (
    <AuthGuard>
      <PrivateExampleComponent />
    </AuthGuard>
  )
}

Guest Guard

The GuestGuard component can be used to protect a route from authenticated users.
import GuestGuard from "../components/guards/GuestGuard";
        
function Component() {
  return (
    <GuestGuard>
      <PublicExampleComponent />
    </GuestGuard>
  )
}