At its heart, SaneJS is just a starter-kit for server-rendered templates built with HTMX, Express, and Mongoose. It comes all wired up out of the box with error handling, file-based routing, a simple but powerful templating engine, TailwindCSS based theme system, LiveReload, and middleware helpers.
What's in the box
my-sane-project/ devops/ # Scripts for deploying and managing pm2 lib/ # Middleware, MongoConnection, Logger models/ # Mongoose models routes/ # HTML templates with inline server-side scripts static/ # Static files like images and CSS style/ # Tailwind CSS compiles to /static/css/bundle.css app.js # The main Express app / entry point .env # Mongo connection, app port, etc.
5,000 foot view of a SaneJS app
Using file-based routing, Sane will look in the
routes/ directory for a match. If one is found, it will be rendered with its partials, layouts, and front matter. If a server block was also defined for this route, Express will execute that code and render the template with locals parsed in. This all done on the server-side.
Once a template is downloaded to the user's browser, HTMX is used to facilitate partial DOM replacements, and Hyperscript can be used for client-side DOM manipulation and animation making the app feel far more fluid and interactive.
- Download and
npm run dev