Enable rendering JSX or HTML in route files #63641
maybephilipp
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
I have some routes that define some server-side logic before showing redirection/showing some content.
For example, I need to generate a referral code before redirecting to another service. So I give user a link
/myapi/service
and then redirect tohttps://service.com?referral=12313123
.All good, but when something goes wrong or I just want to show some validation error, I don't have any options except showing user plain JSON in response. In case JSX was supported, I could render an error page.
Currently I solved it by creating
error_code -> jsx
map and then I redirect user to /public-error?code=blabla and render what I want. But it creates unnecessary code complexity.Please allow rendering JSX/HTML.
Proposal
Maybe it's possible to implement:
NextResponse.jsx(<JSX />)
orNextResponse.jsx('./path-to-template.jsx')
orNextResponse.html('<html></html>')
?Beta Was this translation helpful? Give feedback.
All reactions