A production-ready fullstack template with Nhost Auth + Spring Boot JWT validation. React 19, Spring Boot 3.4, PostgreSQL—all pre-configured.
- Hybrid architecture - Nhost handles auth, Spring Boot validates JWTs
- Ship in days, not weeks - Auth, database, security all working
- Modern tech stack - Spring Boot 3.4 + Java 24, React 19 + Vite 7
- No vendor lock-in - Your data in your PostgreSQL
- JWKS validation - Secure JWT validation against Nhost public keys
┌─────────┐ ┌──────────┐ ┌──────────────┐ ┌─────────────┐
│ Browser │────▶│ React │────▶│ Nhost │────▶│ Spring │
│ │ │ (Front) │ │ Auth │ JWT │ Boot │
└─────────┘ └──────────┘ └──────────────┘ │ (Backend) │
│ │
│ Validates │
│ JWT via JWKS│
│ │
└──────┬───────┘
│
▼
┌─────────────┐
│ PostgreSQL │
│ (your data) │
└─────────────┘
- Sign in via Nhost → Get JWT
- Frontend calls backend →
Authorization: Bearer <JWT> - Backend validates JWT → Against Nhost JWKS
- Backend extracts userId → Stores data in PostgreSQL
Go to nhost.io, create a project, and get:
- Subdomain & Region
- JWKS URL (auto-generated)
git clone https://github.com/your-username/your-repo.git
cd your-repo
cp frontend/.env.example frontend/.env.developmentFrontend (frontend/.env.development):
VITE_NHOST_SUBDOMAIN=your-subdomain
VITE_NHOST_REGION=us-east-1
VITE_API_BASE_URL=http://localhost:8080/apiBackend (backend/.env):
# Nhost (for JWT validation)
nhost.subdomain=your-subdomain
nhost.region=us-east-1
# PostgreSQL (for business data)
DB_URL=jdbc:postgresql://localhost:5432/your_db
DB_USERNAME=postgres
DB_PASSWORD=your_password# Backend
cd backend && mvn spring-boot:run
# Frontend
cd frontend && npm install && npm run dev| Component | Technology | Purpose |
|---|---|---|
| Auth | Nhost | User management, JWT issuance |
| Backend | Spring Boot 3.4, Java 24 | Business API, JWT validation |
| Database | PostgreSQL | Your business data |
| Frontend | React 19, Vite 7, TailwindCSS | UI, Nhost SDK |
| Security | Spring Security, JWKS | JWT validation, headers |
├── backend/ # Spring Boot application
│ ├── src/main/java/com/template/
│ │ ├── config/ # Security config
│ │ ├── controller/ # REST endpoints
│ │ ├── entity/ # Database entities
│ │ ├── repository/ # Spring Data JDBC
│ │ └── security/ # JWT validation, filters
│ └── src/main/resources/db/migration/
├── frontend/ # React application
│ └── src/
│ ├── api/ # Backend API client (with JWT)
│ ├── context/ # Nhost auth context
│ ├── lib/ # Nhost client config
│ └── pages/ # Route pages
└── docs/ # Documentation
@GetMapping("/api/user/me")
public ResponseEntity<Map<String, Object>> getCurrentUser(Authentication auth) {
// Get userId from JWT (validated by JwtAuthenticationFilter)
Map<String, Object> details = (Map<String, Object>) auth.getDetails();
String userId = (String) details.get("userId");
// Use userId to fetch/store data in your PostgreSQL
User user = userRepository.findById(UUID.fromString(userId)).orElse(...);
return ResponseEntity.ok(user);
}import { nhost } from '@/lib/nhost';
// Sign in
const { session, error } = await nhost.auth.signIn({
email: 'user@example.com',
password: 'password',
});
// Call backend (JWT automatically added)
const response = await fetch('/api/user/me', {
headers: {
Authorization: `Bearer ${nhost.auth.getAccessToken()}`
}
});# Backend
cd backend && mvn test
# Frontend
cd frontend && npm test- Nhost Config Guide - JWKS setup, JWT validation
After cloning:
- Rename package: Find/replace
com.templatewith your package - Update pom.xml: Change
groupIdandartifactId - Add your tables: Create Flyway migrations in
db/migration/ - Add endpoints: Extend controllers with your business logic
MIT License - use this template for anything!
Built for developers who ship. ⚡