Redirect
Redirect immediately redirects the browser to the URL in its to property when it gets visible (its when property gets true). It works only within App, not externally.
Using Redirect
The following app demonstrates two different patterns for using Redirect.
- When you navigate to the "Redirect #1" page, it immediately redirects the app to the "Accounts" page. By default, the
whenproperty ofRedirect(and any other component) is "true", so redirection immediately happens. - The "Redirect #2" page expects you to click the button before redirecting. The button click sets the
whenproperty ofRedirectto true, and redirection happens at that moment.
<App>
<NavPanel>
<NavLink to="/">Home</NavLink>
<NavLink to="/accounts">Accounts</NavLink>
<NavLink to="/products">Products</NavLink>
<NavLink to="/redirect1">Redirect #1</NavLink>
<NavLink to="/redirect2">Redirect #2</NavLink>
</NavPanel>
<Pages>
<Page url="/">Home</Page>
<Page url="/accounts">Accounts</Page>
<Page url="/products">Products</Page>
<Page url="/redirect1">
<Redirect to="/accounts" />
Redirecting to Accounts...
</Page>
<Page url="/redirect2">
<Fragment var.clicked="{false}">
<Button label="Click to redirect" onClick="clicked = true"/>
<Redirect when="{clicked}" to="/accounts" />
Redirecting to Accounts...
</Fragment>
</Page>
</Pages>
</App>Example: providing children
<App>
<NavPanel>
<NavLink to="/">Home</NavLink>
<NavLink to="/accounts">Accounts</NavLink>
<NavLink to="/products">Products</NavLink>
<NavLink to="/redirect1">Redirect #1</NavLink>
<NavLink to="/redirect2">Redirect #2</NavLink>
</NavPanel>
<Pages>
<Page url="/">Home</Page>
<Page url="/accounts">Accounts</Page>
<Page url="/products">Products</Page>
<Page url="/redirect1">
<Redirect to="/accounts" />
Redirecting to Accounts...
</Page>
<Page url="/redirect2">
<Fragment var.clicked="{false}">
<Button label="Click to redirect" onClick="clicked = true"/>
<Redirect when="{clicked}" to="/accounts" />
Redirecting to Accounts...
</Fragment>
</Page>
</Pages>
</App>Behaviors
This component supports the following behaviors:
| Behavior | Properties |
|---|---|
| Animation | animation, animationOptions |
| Bookmark | bookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc |
| Component Label | label, labelPosition, labelWidth, labelBreak, required, enabled, shrinkToLabel, style, readOnly |
| Publish/Subscribe | subscribeToTopic |
| Tooltip | tooltip, tooltipMarkdown, tooltipOptions |
| Styling Variant | variant |
Properties
replace
default: false
This boolean property indicates whether the redirect should replace the current history entry or create a new one.
to
default: ""
This property defines the URL to which this component is about to redirect requests.
Events
This component does not have any events.
Exposed Methods
This component does not expose any methods.
Styling
This component does not have any styles.