Skip to content
/ bun-htmx Public template
forked from danawoodman/bun-htmx

An example app using Bun's built-in HTTP server + HTMX + TailwindCSS + DaisyUI

Notifications You must be signed in to change notification settings

kuryart/bun-htmx

 
 

Repository files navigation

Bun + HTMX + TailwindCSS example app

Forked from danawoodman/bun-htmx

A simple example app using Bun and it's HTML server along with HTMX for interactivity and Tailwind + DaisyUI for styling.

Source code can be found in ./src. JSX components live in ./src/components.

Components are converted to static strings and served as HTML to the browser. HTMX is used to add interactivity to the page as needed.

TailwindCSS classes can be given to any component and the bun dev:postcss command will regenerate the CSS file when needed.

There is a very dumb/simple static file server in ./src/response.tsx which takes any file in ./public and serves it using the Bun.file helper. This probably shouldn't be used in any production capacity and instead you should use a static file server for these files, but it's here for demonstration purposes.

Setup

Clone the repo and make sure you have Bun installed, then:

bun i

Development

# Run dev server with hot reload (in one tab)
bun dev

Now open up http://localhost:3000 to see the app running.

If you want a custom port or to enable dev mode, create a .env file:

PORT=3000
NODE_ENV="development"

Production

Build a compiled version of the server for running in Bun and an optimized CSS with PostCSS:

bun run build

Now run the built production bundle:

bun start

Deployment

This projet includes a Dockerfile and docker-compose.yml file so you can run anywhere Docker is supported.

Using Fly.io, you can deploy this by running:

flyctl launch

On subsequent changes, run:

flyctl deploy

Credits

Put together by Dana Woodman, with some extra features.

License

MIT

Use it however you please. Tweet me if you do something cool with it 🤓

About

An example app using Bun's built-in HTTP server + HTMX + TailwindCSS + DaisyUI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 78.1%
  • Dockerfile 17.1%
  • JavaScript 4.0%
  • CSS 0.8%