Return Astro (HTML) components from API endpoints #615
Closed
unbiased-dev
started this conversation in
Proposal
Replies: 3 comments 2 replies
-
Relates to Support for Partials #697 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Currently using partials works fine, but it gets harder when you try to implement a RESTful API with it. You need to define different endpoints for different HTTP methods. You certainly can |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing as this is achievable with the container API |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
Enabling of returning Astro components (as stringified prerenderd html) from api endpoints.
Background & Motivation
This would allow frameworks such as HTMX to pair nicely with Astro.
Currently the only way to do this is to have your partials be Astro pages, which is finicky at best with pitfalls such as the partials having their own hardlink (which you can mitigate by redirecting to 404 if the HTMX headers are not there), or you have to write yet another abstraction of said partials in another markup (string litterals, vhtml, ...) which is far from ideal.
Goals
pages/api
folderrenderToString
like methodExample
Proposal 1 (pseudo code):
or
Proposal 2
or
Proposal 3
Beta Was this translation helpful? Give feedback.
All reactions