A very simple demonstration of the use of htmx with a http4s server together with twirl templates.
This application implements the classic 'To Do' application with a database (JDBC) backend.
Requirements: JDK >= 17 and Sbt.
Once Java & sbt are installed, clone this project, and run sbt run
from the project root.
You should see this line in the console: -
2024-01-17 19:50:25.464 INFO [io-compute-5] n.m.d.HtmxDemoServer - Ember-Server service bound to address: [::]:8080
Point your browser to http://localhost:8080
and you should see the following page: -
Change the logback.xml file to see/hide debug messages.
The code uses an (in memory) h2 database by default. The JDBC connection parameters are stored in application.properties.
- The database integration is implemented with Doobie a pure functional JDBC layer for Scala and Cats
- WebJars are used to install and manage Bootstrap, and htmx. More information on using WebJars with http4s.
- The project also includes the sbt-revolver plugin. This means you can use the command
~ reStart
on the sbt commandline and the server will restart on any code change.