A modern fullstack web application built with Go (Golang) backend and React + TypeScript frontend using Vite. This project demonstrates how to create a production-ready web application with authentication, static file serving, and containerized deployment.
- Framework: Fiber - Fast, Express-inspired web framework
- Authentication: Firebase Authentication integration
- Static Serving: Embedded React build with Go's embed directive
- Configuration: Environment-based configuration with dotenv support
- Middleware: CORS, Recovery, and Firebase Auth middleware
- Framework: React 19 with TypeScript
- Build Tool: Vite for fast development and optimized builds
- Package Manager: PNPM for efficient dependency management
- Linting: ESLint with TypeScript and React-specific rules
- Styling: CSS with modern features and responsive design
- Containerization: Multi-stage Docker build
- Platform: Fly.io deployment ready
- Environment: Alpine Linux for minimal image size
- β‘ Fast Development: Hot reload for both frontend and backend
- π Authentication: Firebase Authentication integration
- π± Responsive: Mobile-first design approach
- π³ Containerized: Docker support for easy deployment
- π§ Type Safe: Full TypeScript support with strict configuration
- π¦ Optimized: Static file embedding and production builds
Before you begin, ensure you have the following installed:
- Go (version 1.23.6 or higher)
- Node.js (version 18 or higher)
- PNPM (for frontend package management)
- Docker (for containerization)
- Make (for build automation)
git clone https://github.com/yusupscopes/golang-fullstack-vite.git
cd golang-fullstack-vite
Create a .env
file in the root directory:
# Server Configuration
PORT=8080
# Firebase Configuration
GOOGLE_APPLICATION_CREDENTIALS=path/to/your/firebase-service-account.json
# Database Configuration (optional)
DB_CONNECTION_STRING=your-database-connection-string
go mod download
cd ui
pnpm install
cd ..
Run both frontend and backend in development mode with hot reload:
make dev
This will start:
- Frontend dev server on
http://localhost:3000
- Backend server on
http://localhost:8000
make start-ui-dev
go run main.go
Build the application for production:
make build
This will:
- Install frontend dependencies
- Build the React application
- Generate Go embed files
- Compile the Go binary
The final binary will be available in build/app
.
docker build -t golang-fullstack-vite .
docker run -p 8080:8080 golang-fullstack-vite
make start
make deploy
Make sure you have flyctl installed and configured.
golang-fullstack-vite/
βββ main.go # Main Go application entry point
βββ go.mod # Go module dependencies
βββ go.sum # Go module checksums
βββ config/
β βββ config.go # Configuration management
βββ ui/ # Frontend React application
β βββ src/
β β βββ App.tsx # Main React component
β β βββ main.tsx # React entry point
β β βββ index.css # Global styles
β βββ package.json # Frontend dependencies
β βββ vite.config.ts # Vite configuration
β βββ tsconfig.json # TypeScript configuration
β βββ embed.go # Go embed file for static assets
βββ Makefile # Build automation
βββ Dockerfile # Docker configuration
βββ README.md # This file
Variable | Description | Default |
---|---|---|
PORT |
Server port | 8080 |
GOOGLE_APPLICATION_CREDENTIALS |
Firebase service account path | "" |
DB_CONNECTION_STRING |
Database connection string | "" |
- Create a Firebase project at Firebase Console
- Enable Authentication in your Firebase project
- Download your service account key
- Set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable
make build
- Build the entire applicationmake dev
- Start development serversmake start-ui-dev
- Start frontend development servermake start
- Start with Docker Composemake deploy
- Deploy to Fly.io
The project includes:
- ESLint for JavaScript/TypeScript linting
- TypeScript strict mode for type safety
- Go modules for dependency management
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This project was inspired by the excellent tutorial on setting up a fullstack Golang application with Vite by Ahmad Rosid. Check out the original guide at: https://ahmadrosid.com/blog/setup-fullstack-golang-with-vite
If you encounter any issues or have questions, please:
- Check the Issues page
- Create a new issue with detailed information
- Include your environment details and error messages
Built with β€οΈ using Go, React, and Vite