:::Note 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.
import React from 'react'
import RedirectWithStatus from '@salesforce/pwa-kit-react-sdk/ssr/universal/components/redirect-with-status'
const ExamplePage = () => {
return (
<RedirectWithStatus status={301} to='/login' />
)
}