Skip to content

Conversation

@brookslybrand
Copy link
Contributor

Fixes #12888

I took a stab at letting AI summarize @brophdawg11 comment (#12888 (comment)) and then updating the Resource Route doc

I've given it a review and I think this improves the existing doc. Please share if you feel any other docs need to be updated from the original conversation in the issue or if you think the update is still unclear/missing anything

…idelines for internal and external access methods.
@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2025

⚠️ No Changeset found

Latest commit: b9e4d65

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

{ status: 404 },
);
}
While we don't recommend it, you _can_ return plain JS objects from a resource route and they will be converted into an appropriate `Response` based on to the HTTP Request (a single-fetch response for `.data` requests or a JSON response for other external HTTP requests). We don't prefer this pattern because `new Response()`/`data()` calls keep the code explicit for API-only/non-UI routes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has enough "don't do this" language that I almost wonder if it's worth just removing/not mentioning. If you feel it needs to be explained though, that's fine. I think I would just flip it around a little:

It is recommended that you return `new Response()`/`data()` calls from resource routes keep the code explicit for API-only/non-UI routes. While you _can_ return a plain JS objects from a resource route, they will be converted into different a `Response` based on to the HTTP Request (a single-fetch response for `.data` requests or a JSON response for other external HTTP requests).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I went back and forth on that too - let's just remove it

@brophdawg11 brophdawg11 merged commit 132c160 into main Nov 10, 2025
1 check passed
@brophdawg11 brophdawg11 deleted the brooks/resource-routes-error-handling-doc branch November 10, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs]: It is unclear how to return errors from server-side Resource Routes

3 participants