diff --git a/docs/how-to/resource-routes.md b/docs/how-to/resource-routes.md index d3ccb1a52f..dc682de1f8 100644 --- a/docs/how-to/resource-routes.md +++ b/docs/how-to/resource-routes.md @@ -65,3 +65,62 @@ export function action(_: Route.ActionArgs) { }); } ``` + +## Return Types + +Resource Routes are flexible when it comes to the return type - you can return [`Response`][Response] instances or [`data()`][data] objects. A good general rule of thumb when deciding which type to use is: + +- If you're using resource routes intended for external consumption, return `Response` instances + - Keeps the resulting response encoding explicit in your code rather than having to wonder how React Router might convert `data() -> Response` under the hood +- If you're accessing resource routes from [fetchers][fetcher] or [`