HTMX Development Toolkit
A set of guidelines and best practices for building efficient and secure web applications using HTMX.
HTMX Best Practices
- Implement
hx-getandhx-postfor GET and POST requests. - Use
hx-triggerfor custom events andhx-swapfor content swapping. - Utilize
hx-targetandhx-indicatorfor precise content updates and loading indicators.
Folder Structure and Organization
Organize code into a structured directory:
textsrc/
templates/
static/
css/
js/
app.py
Additional Development Guidelines
- Use semantic HTML5 elements for clarity and accessibility.
- Implement proper CSRF protection for security.
- Leverage HTMX extensions when needed.
- Use
hx-boostfor full page navigation. - Follow progressive enhancement principles for robustness.
Key Features
- Efficient Request Handling: Streamline GET and POST requests with HTMX attributes.
- Dynamic Content Swapping: Control how content is updated with
hx-swapandhx-target. - Security and Accessibility: Ensure robust security with CSRF protection and semantic HTML.
Overview of .cursorrules prompt
This prompt outlines guidelines and best practices for developing applications using HTMX, a library that enhances static HTML with dynamic capabilities. It provides a structured approach to implementing HTMX, focusing on efficient request handling, content swapping, and error management. Additionally, it emphasizes the importance of semantic HTML, proper security measures like CSRF protection, and progressive enhancement principles to ensure robust and maintainable web applications. By following these guidelines, developers can create interactive web pages that are both user-friendly and secure.
