HTMX integration with Astro (Meta framework) #1425
Replies: 3 comments 3 replies
-
It would be great! I'm building a website using Astro and I really miss some htmx utilities. |
Beta Was this translation helpful? Give feedback.
-
Hi, It appears to be quite straightforward to integrate htmx into Astro; or are there specific features that you've found aren't available? Basically as long as your "backend" can take in requests and return HTML, optionally with specific headers, it should be good to work with htmx regardless of the language/framework For Astro, this worked for me:
// say_hi.html.js file
export async function get({ params, request }) {
return {
body: 'Hello World',
};
} <!-- content of index.astro's template -->
<main>
<button hx-get="say_hello.html" hx-target="#outcome">Click me</button>
<div id="outcome"></div>
</main> Hope this helps |
Beta Was this translation helpful? Give feedback.
-
@FlorentDardenne There is https://github.com/xstevenyung/astro-htmx which could be sufficient already. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I discovered recently Astro and Htmx (yesterday). Two amazing tools for SSR websites !
An implementation htmx/Astro sample should be very interesting package (and a good way to promote Htmx).
Regards,
Florent
Beta Was this translation helpful? Give feedback.
All reactions