CxJS

RedirectRoute

import { RedirectRoute } from 'cx/widgets'; Copied

RedirectRoute automatically redirects to another URL when matched. It uses replaceState, so the browser back button won’t return to the redirected URL.

Usage

<RedirectRoute route="~/" url={m.url} redirect="~/dashboard" />

Common use cases:

  • Redirect from root to a default page
  • Redirect legacy URLs to new locations
  • Redirect unauthenticated users to login

Configuration

PropertyTypeDescription
routestringRoute pattern to match
urlProp<string>Binding to the current URL
redirectstringTarget URL to redirect to