Description
gomponents is a library for building HTML components in pure Go. You write HTML as Go functions, such as Nav, Ol, Li and A, and the library renders them to HTML 5. Components are just functions, so you can factor out a navbar item, reuse it, pass in data and map a slice of values to a list of components. Conditional content is handled with If and Iff, and the site notes that Iff takes a callback to avoid nil pointer errors. The project is aimed at Go developers who find template languages hard to work with. Because components are ordinary Go code, you use the same tools, types and tests as the rest of your application, and you do not learn another templating language. You can install it with go get maragu.dev/gomponents. The site lists examples and templates, a starter kit on GitHub, and online converters that turn HTML into gomponents code. A video introduction from a GopherCon 2021 lightning talk is linked from the page. The project is developed on GitHub, and the author invites companies that depend on it to contact him about one-time or recurring support invoices.…
Highlights
- HTML components written as Go functions
- Renders to HTML 5
- Conditional and mapped components
- Starter kit and examples
- HTML-to-gomponents converters
Ratings & Reviews
No ratings yet
Be the first to rate Gomponents.
People also visit
Gomponents FAQ
What is gomponents?
A library for writing HTML components in pure Go, rendering to HTML 5.
How do I install it?
Run go get maragu.dev/gomponents.
How are components written?
As Go functions that return a node, using helpers such as Nav, Ol, Li and A.
How do I show something conditionally?
Use If, or Iff, which takes a callback instead of a value.
Is there a starter?
Yes. The site links a gomponents starter kit on GitHub and examples in the repository.
Can I support the project?
The author invites companies that depend on it to contact him about a one-time or recurring invoice to support its development.
What are the best Gomponents alternatives?
Popular alternatives to Gomponents include Genesis, MyGo and Svelte. See all Gomponents alternatives









