Skip to content

Feature Request: Support statusCode in ssrContext and <Route /> #535

@amadsen

Description

@amadsen

Similar to how ssrContext.redirectTo is used, it would be useful to be able to specify an HTTP status code on a Route component like this:

<>
      <Link to='/'>Home</Link>
      <Link to='test'>Test</Link>
      <Switch>
        <Route path='test' statusCode={200}>
          <Test />
        </Route>
        <Route path='/' statusCode={200}>
          <Home />
        </Route>
        <Route statusCode={404}>
          <NotFound />
        </Route>
      </Switch>
    </>

and have that status code show up as ssrContext.statusCode. (If not set, it should default to 200 or remain undefined.) This would primarily be useful in the NotFound case, but other use cases may also arise. React's renderToReadableStream proposes throwing Error's to be caught by an onError handler which either interrupts server side rendering or requires wrapping the throwing component in a Suspense component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions