Contacts

Plain htmx CRUD with validation, OOB swaps, and response headers

1 min read 167 words

What It Teaches

This is the baseline Chirp CRUD app without ChirpUI. Read it after the first fragment app when you want realistic htmx workflows:

  • Page(...)for full page vs fragment negotiation
  • Fragment(...)for search and delete updates
  • ValidationError(...)for 422 form re-renders
  • OOB(...)for updating the table and count in one response
  • HX response headers for toast-style UX
  • frozen dataclasses plus a lock for thread-safe in-memory state

Run It

PYTHONPATH=src python examples/standalone/contacts/app.py

Open http://127.0.0.1:8000/.

Test It

pytest examples/standalone/contacts/

Contract Surface

This example is a good fixture for htmx correctness: table rows, form fragments, OOB counters, and validation errors all depend on named blocks matching the Python return values. It also shows why broadhx-targetselectors are risky: the table target is an explicit#contact-table, and OOB updates use the separate#contact-counttarget.

Source

Next