Back to articles
htmx Is Not a Framework — It Is a Better Way to Build Web Apps

htmx Is Not a Framework — It Is a Better Way to Build Web Apps

via Dev.to TutorialAlex Spinov

JavaScript Frameworks Solved a Problem Most Apps Do Not Have Most web apps are CRUD. Forms, lists, dashboards. You do not need React for that. htmx lets you build interactive web apps using HTML attributes instead of JavaScript. Before htmx (React) // UserList.jsx - 50 lines function UserList () { const [ users , setUsers ] = useState ([]); const [ loading , setLoading ] = useState ( true ); useEffect (() => { fetch ( " /api/users " ). then ( r => r . json ()). then ( data => { setUsers ( data ); setLoading ( false ); }); }, []); if ( loading ) return < div > Loading... </ div >; return < ul > { users . map ( u => < li key = { u . id } > { u . name } </ li >) } </ ul >; } After htmx (HTML) <div hx-get= "/api/users" hx-trigger= "load" hx-indicator= "#spinner" > <div id= "spinner" class= "htmx-indicator" > Loading... </div> </div> Server returns HTML, not JSON. No state management. No build step. No node_modules. Common Patterns Click to Load More <button hx-get= "/api/users?page=2" hx-t

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
0 views

Related Articles