Skip to content

Let a rejection declare an http status - #827

Open
pleek91 wants to merge 2 commits into
ssr-async-propsfrom
rejection-status
Open

Let a rejection declare an http status#827
pleek91 wants to merge 2 commits into
ssr-async-propsfrom
rejection-status

Conversation

@pleek91

@pleek91 pleek91 commented Aug 29, 2026

Copy link
Copy Markdown
Member

Description

A server rendering the app needs to know what status to respond with, and the rejection in effect is the thing that knows. Adds an optional status to createRejection, and declares 404 on the built in NotFound rejection.

Nothing reads it yet — router.render does, later in the stack.

const unauthorized = createRejection({ type: 'Unauthorized', status: 401 })

@netlify

netlify Bot commented Sep 2, 2026

Copy link
Copy Markdown

Deploy Preview for kitbag-router ready!

Name Link
🔨 Latest commit 054e6b2
🔍 Latest deploy log https://app.netlify.com/projects/kitbag-router/deploys/6a9843e0b1b65200074a57f4
😎 Deploy Preview https://deploy-preview-827--kitbag-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

…hing

A url matching no route committed the NotFound route and cleared the rejection, so the
most common rejection in any app was the one that never set one. onRejection never fired
for a 404, useRejection reported null, and the two ways to reach the same NotFound
screen left completely different state behind.

Set the rejection instead. The rendered output is unchanged: RouterView reaches the same
component through the rejection rather than through the route.

The route is still seeded with the NotFound route, so useRoute keeps working outside
RouterView. That the seeded route is not one of the caller's declared routes remains a
separate problem.
A server rendering the app needs to know what to respond with, and the rejection in
effect is the thing that knows. Adds an optional status to createRejection, and declares
404 on the built in NotFound rejection.

Nothing reads it yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant