Skip to content

Jason-CKY/go-htmx-example

Repository files navigation

Go htmx server

Dependencies

  • docker (docker-desktop if you are using windows)
  • docker-compose (comes with docker-desktop, but can install here if you are not on windows)
  • Node LTS v18
  • Go v1.21
  • Air
  • templ

Features

Recording.2023-11-08.134353.mp4
  • echo web server that serves html on htmx endpoints
  • templ templates
  • HTMX for interactivity, minimal js needed
  • Lazy loading with HTMX
  • tailwind for CSS Styling
  • DaisyUI with theme-changing library for CSS styling and themes
  • SortableJS for drag and drop of tasks (sorting and updates)
  • Directus for headless CMS and API routes for CRUD operations

Quickstart (development mode)

You can either start up using docker-compose:

# Run install-deps once to install all dev dependencies
make install-deps
make build-dev
# make sure directus is up on http://localhost:8055 before running migrations for directus
make initialize-db

Or you can run locally with:

# start directus
docker-compose -f docker-compose.dev.yml up directus -d
# make sure directus is up on http://localhost:8055 before running migrations for directus
make initialize-db
# install air
go install github.com/cosmtrek/air@latest
# install templ
go install github.com/a-h/templ/cmd/templ@latest
# start golang server with code reload using air
air

Format on save

Add the following config into your vscode settings.json to enable format on save of a file in vscode:

"editor.formatOnSave": true,

VS-code extensions for good developer experience

Syntax highlighting of golang template files on vscode

  • Download templ-vscode vscode extension for go-templ syntax highlighting
  • Add the following into your vscode settings.json to allow for tailwind syntax highlighting in your go templ files:
"tailwindCSS.includeLanguages": {
"templ": "html"
}

About

example todo app with golang and htmx

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published