Boilerplate Pocketbase-G + HTMX + Tmpl

by Marko Veselinovic

Default main.go looks like this:

(“bragi/template” is “go module/directory”)

package main

import (




func main() {
app := pocketbase.New()

// serves the templ.Handler instead of the static files directory

app.OnBeforeServe().Add(func(e *core.ServeEvent) error {

e.Router.GET("/", func(c echo.Context) error {

templ.Handler(template.Hello("GO", "HTMX", "Pocketbase")).ServeHTTP(c.Response(), c.Request())

return nil
return nil


if err := app.Start(); err != nil {

This is the referenced template, located in ./template/

package template


templ Hello(back, front, db string){

<h1>Welcome to the simple stack</h1>

<p>You are extending {db} with {back} to run the server</p>

<p>And the server is returning HTML thanks to {front}</p>


And the templ file is on this link

The command to generate .go files from .templ is:

./templ generate (on MacOS)

It requires the executable.

The Hello template is served on localhost:8090, Admin UI on localhost:8090/_/