A modern web application stack for the fullstack dev that wants something different from the usual stack. REGoTTH stands for React, Go, Tailwind, Templ, and HTMX.
This project serves as a reference implementation demonstrating how to effectively integrate these technologies in a clean and opinionated way.
- π Tech Stack
- π Project Structure
- π Architecture
- π Getting Started
- π― React Components Integration
- π§ͺ Testing
- π§ Available Make Commands
- π Troubleshooting
- π License
- Go - Backend server and business logic
- HTMX - Frontend interactivity without JavaScript
- Templ - Type-safe HTML templating
- TailwindCSS - Utility-first CSS framework
- React - Component-based UI library
- Bun - JavaScript runtime and package manager
.
βββ internal/
β βββ entity/ # Business entities/models
β βββ repository/ # Data access layer
β βββ service/ # Business logic layer
β βββ server/ # HTTP server configuration
β βββ middleware/ # HTTP middleware
βββ web/
β βββ component/ # Reusable UI components
β βββ view/ # Page templates
β βββ controller/ # HTTP request handlers
βββ static/
β βββ css/ # TailwindCSS files
β βββ js/ # TypeScript & React components
β βββ build/ # Compiled assets
βββ main.go # Application entry point
The project follows a clean architecture pattern:
- Entity Layer (
internal/entity/
) - Contains business models - Repository Layer (
internal/repository/
) - Handles data persistence - Service Layer (
internal/service/
) - Implements business logic - Controller Layer (
web/controller/
) - Handles HTTP requests - View Layer (
web/views/
&web/components/
) - Manages UI templates - React Components (
static/js/components/
) - Client-side interactive components
- Go 1.23.4 or higher
- Make (for running commands)
- Air (for live reload) -
go install github.com/air-verse/air@latest
- Templ (for generating templates) -
go install github.com/a-h/templ/cmd/templ@latest
- Bun (for running the JavaScript/React components) -
brew install bun
- jq (optional: used for renaming the module) -
brew install jq
-
Clone the repository
git clone https://github.com/Neofox/regotth.git my-project cd my-project make rename-module NEW_NAME=github.com/username/my-project rm -rf .git git init
-
Install dependencies
go mod download
bun install
To see all available commands:
make help
For development with live reload:
make live
This will start:
- Go server with hot reload
- Templ template generation with hot reload
- TailwindCSS compilation
- React components compilation with hot reload
π‘ Note: Always use the proxy URL (http://localhost:7331) during development to ensure all live-reload features work correctly.
make build
This will build the project for production and output the binary to the tmp
directory.
-
Create your component in
static/js/components/
:// As we also use preact/compat we can use the normal react syntax // /!\ React has to be imported even if we don't use it! import React, { useState, type ReactNode } from "react"; export function MyComponent(): ReactNode { const [count, setCount] = useState(0); return <div>My Component {count}</div>; }
-
Use it in your Templ templates:
<div data-react-component="MyComponent" />
The component will be automatically loaded when it appears in the DOM.
The project automatically generates Go types from React component props, ensuring type safety between React components and Templ templates. When you create or modify a React component with props:
-
Define your props interface in your React component:
export interface MyComponentProps { prop1: string; prop2?: number; }
-
The types will be automatically generated when:
- Running
make build
- During development with
make live
- Manually with
bun run generate-props
The generated types will be available inweb/generated/react_component_props.go
- Running
-
Use the generated types in your Templ templates:
<div data-react-component="Button" data-react-props={ props.ButtonProps{ Id: "123", Label: "Click me", }.String() } />
go test ./...
Run make help
to see all available commands. Here are the main ones:
make live
- Start development server with live reloadmake build
- Build the project for production
make rename-module NEW_NAME=your-module-name
- Rename the Go module and package name
-
If
make rename-module
fails:# Clean up any partial changes git checkout go.mod git checkout package.json # Ensure jq is installed brew install jq # Try again with the full path make rename-module NEW_NAME=github.com/username/project-name
-
"templ command not found":
go install github.com/a-h/templ/cmd/templ@latest export PATH=$PATH:$(go env GOPATH)/bin
-
"bun command not found":
curl -fsSL https://bun.sh/install | bash source ~/.bashrc # or source ~/.zshrc
-
Missing dependencies:
# Reset Go modules rm -rf go.sum go mod tidy # Reset npm modules rm -rf node_modules bun install
-
Verify all prerequisites are installed:
go version # Should be 1.23.4 or higher templ version bun --version
-
Clean and rebuild:
# Full cleanup rm -rf tmp/ node_modules/ static/build/* # Fresh install go mod download bun install make build
This project is licensed under the MIT License - see the LICENSE file for details.