LopezNoah / Astro-Dynamic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Astro Dynamic Component

This repository was created to demonstrate a "Proof of Concept" Dynamic component.

The Dynamic Astro component uses data attributes to fetch the actual component from the server through an API endpoint. Once the actual component has been fetched, we replace the contents of the DOM with the newly-fetched component.

The script in the Dynamic component can be replaced with HTMX if desired. Using HTMX and endpoints that return partail components would reduce the complexity of the component. It cleans up the script into just using HTMX attributes like hx-get, hx-swap, and hx-target but its up to the developer to decide if they want to do that. Either solution works for fetchin dynamic content.

About


Languages

Language:Astro 91.2%Language:TypeScript 5.2%Language:JavaScript 3.6%