Some websites like Reddit expose a .json endpoint alongside each post. For example, the posts shown in https://www.reddit.com/r/rickroll/ are also exposed in https://www.reddit.com/r/rickroll.json.
Here's how we can do the same in Remix:
If $postId.tsx was our post's UI route, we can create a file called $postId[.json].ts with the following:
export { loader } from "./$postId";
Note that we escape [.json] due to Remix conventions
Top comments (0)