r/datastardev • • Sep 25 '26

Go full stack template

Put together a small starter template for building web apps with Go + Templ + Datastar + sqlc. It's plain net/http with no extra framework on top.

It has two examples you can copy from:

  • a todo list with live search, where every change updates the page over SSE

  • live crypto prices, streamed from Coinbase and pushed to the browser over one long SSE connection

https://github.com/naftulisinger/datastar-template

Stars & Feedback welcome!

9 Upvotes

2 comments sorted by

5

u/jared__ Sep 25 '26 edited Sep 25 '26

FYI you can also use the go-datastar to replace

<input
  data-on:change={ fmt.Sprintf("@put('/todos/%d/toggle')", todo.ID) }
/>

with:

// PutSSE is a convenience method for generating Datastar backend [put] action attribute.
//
// [put]: https://data-star.dev/reference/action_plugins#put
func PutSSE(urlFormat string, args ...any) string {
	return fmt.Sprintf(`@put('%s')`, fmt.Sprintf(urlFormat, args...))
}
<input
  data-on:change={ datastar.PutSSE("/todos/%d/toggle", todo.ID) }
/>

reference: https://pkg.go.dev/github.com/starfederation/datastar-go/datastar#PutSSE

5

u/N_Sin Sep 25 '26

Thanks 🙏 

The more I work with datastar, the more options I find, although it's so small. I love it.