A modern full-stack application template using Next.js and Go Fiber, featuring a clean UI with shadcn/ui components and a high-performance backend.
- Next.js (App Router)
- TypeScript
- Tailwind CSS
- shadcn/ui components
- pnpm package manager
# Clone the repository
git clone https://github.com/inagib21/nextjs-fiber-template.git
cd nextjs-fiber-template
# Remove the existing git history and start fresh
rm -rf .git
git init
git add .
git commit -m "Initial commit"
The easiest way to run both frontend and backend for local development is using the Vercel CLI:
# Install Vercel CLI if you haven't already
pnpm add -g vercel
# Run the development server (handles both frontend and Go API)
vercel dev
Alternatively, using the Makefile (which may use vercel dev
or separate commands):
# Install dependencies and run both services
make run
# Stop all services
make stop
The frontend will be available at http://localhost:3000
(or as indicated by vercel dev
).
The Go API endpoints will be available under http://localhost:3000/api/...
when using vercel dev
, as it proxies requests.
The Go application in the api/
directory is structured as a Vercel Serverless Function. For local development that mirrors the Vercel environment, use vercel dev
from the project root.
If you wish to run or test Go components independently (outside the full Vercel dev environment), you would typically create a separate main.go
for that purpose.
cd frontend
pnpm install
pnpm dev
This will run the Next.js frontend, typically on http://localhost:3000
. Note that API calls to /api/...
might not work correctly unless the Go API is also being served and proxied (e.g., via vercel dev
).
make run
- Install dependencies and run both frontend and backendmake install
- Install dependencies for both servicesmake run-frontend
- Run only the frontendmake run-backend
- Run only the backendmake stop
- Stop all running services
.
├── api/ # Go Fiber API (Vercel Serverless Functions)
│ └── index.go # Main entry point for the API
│
├── frontend/ # Next.js frontend
│ ├── app/ # Next.js app directory
│ ├── components/# React components
│ └── lib/ # Utility functions and API client
│
├── go.mod # Go modules file (project root)
├── go.sum # Go modules checksum (project root)
├── Makefile # Build and run commands
└── vercel.json # Vercel deployment configuration
- Modern Next.js App Router architecture
- Type-safe development with TypeScript
- Beautiful UI with Tailwind CSS and shadcn/ui
- Responsive design
- Dark mode support
- API integration with backend
- High-performance Go Fiber framework
- Built on top of FastHTTP
- RESTful API structure (served via Vercel Serverless Functions)
- Health check endpoint (
/api/health
) and other example API routes
GET /api/health
- Health check endpoint- Response:
{ "status": "healthy", "message": "Go Fiber API is running!" }
- Response:
GET /api/
- Root of the Go API- Response: Example:
{ "uri": "/api/", "path": "/" }
- Response: Example:
GET /api/v1
- Example v1 endpoint- Response:
{ "version": "v1" }
- Response:
GET /api/v2
- Example v2 endpoint- Response:
{ "version": "v2" }
- Response:
When using vercel dev
, changes to both frontend and backend code should trigger reloads.
- Frontend changes (Next.js): Fast Refresh.
- Backend changes (Go in
api/
):vercel dev
should detect changes and rebuild the Go function.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This template is optimized for deployment on Vercel. The vercel.json
file in the project root configures the builds and routing.
- Push your code to a Git repository (e.g., GitHub, GitLab, Bitbucket).
- Go to Vercel and sign up/login.
- Click "New Project" and import your repository.
- Vercel should automatically detect the Next.js frontend and use the settings from
vercel.json
to build the Go API.- Framework Preset: Should be Next.js (Vercel typically autodetects this for the frontend part).
- Root Directory: Should be
./
(monorepo root). Thebuilds
array invercel.json
explicitly tells Vercel how to build each part (@vercel/next
forfrontend/package.json
and@vercel/go
forapi/index.go
).
- Click "Deploy".
The template includes proper configuration in vercel.json
for both the Next.js frontend and Go serverless functions.
The template uses environment variables for configuration. Set these in your Vercel project settings:
Development:
NODE_ENV=development
Production:
NODE_ENV=production
After deployment, verify your setup by visiting:
- Frontend:
https://your-project.vercel.app
- API Health Check:
https://your-project.vercel.app/api/health
- Other API routes like
https://your-project.vercel.app/api/
orhttps://your-project.vercel.app/api/v1
The frontend includes a "Test Backend Connection" button which calls the /api/health
endpoint.