Trigger Redirects In PWA Kit

To redirect whole pages or assets, use the Redirect functionality provided by Runtime Admin or the Managed Runtime API. See Redirects.

The Progressive Web App (PWA) Kit uses React Router redirects. However, the React Router Redirect component does not let you set a status code.

In PWA Kit 3.9, we added a RedirectWithStatus component that builds on top of the React Router Redirect component and allows you to create redirects with a status code.

Example 

The example below shows how you would add a redirect with an HTTP 301 status from an example page to the login page in your PWA Kit project.

1import React from 'react'
2import RedirectWithStatus from '@salesforce/pwa-kit-react-sdk/ssr/universal/components/redirect-with-status'
3
4const ExamplePage = () => {
5    return (
6        <RedirectWithStatus status={301} to='/login' />
7    )
8}