A reusable starter repository for VK Mini Apps with a separated frontend and backend.
Repository: https://github.com/devflex-pro/vk-mini-app-starter-kit
This project is provided as is. It is intended as a reusable starter, reference implementation, and foundation for new VK Mini Apps, not as a finished production product.
- Frontend:
React + TypeScript + Vite + VKUI v8 + VK Bridge - Backend:
NestJS + TypeScript + MongoDB + Mongoose - Basic VK Mini App initialization
- Shared frontend VK layer in
shared/vk - Shared frontend API client in
shared/api - Basic
entities/usermodel on both frontend and backend - Shared backend auth actor
- Example user sync flow with the backend
- Development fallback for running outside the VK container
- Strict TypeScript checks for frontend and backend
- GitHub Actions CI for frontend and backend
- MIT license
This repository is a starting point for new VK Mini Apps, not a complete product.
Things that are meant to stay:
- Project structure
- Build and environment setup
- VK Bridge integration
- Basic backend modules and validation
Things that are usually replaced in a real project:
- App shell in
frontend/src/app/App.tsx - Example user sync flow
- MongoDB schemas and API endpoints for the target domain
- UI text, screens, and documentation
vk-mini-app-starter-kit/
frontend/
backend/
ReactTypeScriptViteVKUI v8VK Bridge- Feature-Sliced Design as the target starter architecture
Current frontend structure:
frontend/src/
app/
main.tsx
pages/
widgets/
features/
entities/
shared/
Layer responsibilities:
shared/vk: wrappers aroundvk-bridge, launch params parsing, bridge init, user info loading, VK environment detectionshared/api: sharedfetchclient with JSON parsing, headers, and normalized errorsentities/user: user types and thegetUserFullNamedomain utilityfeatures/example-user-sync: orchestration of the demo flow without direct VK logic inside UI componentswidgets/example-user-sync: demo UI block built on top of the featurepages/home: page composition
Intentionally omitted for simplicity:
- Global state manager
- Complex navigation
- Separate design-system layer on top of VKUI
- Complex data-access architecture
NestJSMongoDBMongooseclass-validatorclass-transformer
Current backend structure:
backend/src/
common/
entities/
users/
vk/
Module responsibilities:
common/auth: shared actor contract and current actor decoratorcommon/http: base request type for auth/context dataentities/user: Mongoose schema and user response mappingusers: demo user sync use casevk: launch params validation, guard, decorator, and debug/context endpoint
The starter contains a minimal user flow:
- Frontend initializes
VKWebAppInit. - Frontend requests the user via
VKWebAppGetUserInfo. - In development mode, frontend uses a fallback user when VK Bridge is unavailable.
- Frontend sends launch params to the backend via
Authorization: Bearer .... - Backend validates
sign, checksvk_user_idagainst the request body, and upserts the user byvkId. - Frontend renders loading, error, and success states.
This flow is meant as a working reference integration. For a real project, it can be simplified, replaced, or removed.
Important details:
- The demo flow stays isolated from the app shell.
- Frontend VK logic is not duplicated across components.
- Backend does not trust
vkIdfrom the request body without verified launch params. - Development fallback is available outside production.
With Docker Compose:
docker compose up -dOr manually:
docker run -d \
--name vk-miniapp-mongo \
-p 27017:27017 \
-e MONGO_INITDB_DATABASE=vk_miniapp_starter \
mongo:7cd backend
cp .env.example .env
npm install
npm run start:devBy default, the backend is available at http://localhost:3000, with API routes under /api.
cd frontend
cp .env.example .env
npm install
npm run devBy default, the frontend is available at http://localhost:5173.
PORT=3000
MONGODB_URI=mongodb://localhost:27017/vk_miniapp_starter
FRONTEND_URL=http://localhost:5173
VK_APP_SECRET=VITE_API_URL=http://localhost:3000/apiIf VITE_API_URL is not set, the frontend uses /api.
The starter currently includes one demo users module.
Checks that the users module is available.
Response:
{
"ok": true
}Checks the backend auth/context layer populated by the vk module from launch params.
This endpoint is mainly useful as a starter debug/inspection endpoint.
Response:
{
"actor": {
"appId": 123456,
"isAuthenticated": true,
"isDevFallback": false,
"platform": "mobile_android",
"userId": 123
},
"launchParams": {
"appId": 123456,
"isDevFallback": false,
"isVerified": true,
"platform": "mobile_android",
"userId": 123
}
}Example VK user synchronization with the backend.
For requests from a VK Mini App, the frontend passes launch params in the header:
Authorization: Bearer vk_app_id=...&vk_user_id=...&sign=...
In development mode, the backend allows a local fallback when launch params are missing. This fallback is disabled in production.
Important details:
- The endpoint is a working demo use case.
- Verified VK context comes from the backend guard, not from the request body.
platformand raw VK context are taken from verified launch params when available.- The endpoint structure stays simple so it can be replaced easily in a real project.
Request:
{
"vkId": 123,
"firstName": "Ivan",
"lastName": "Petrov",
"photo200": "https://...",
"photo100": "https://...",
"platform": "mobile_android",
"raw": { "...": "..." }
}Response:
{
"id": "mongo_id",
"vkId": 123,
"firstName": "Ivan",
"lastName": "Petrov",
"photo200": "https://...",
"photo100": "https://...",
"platform": "mobile_android",
"lastSeenAt": "2026-04-10T12:00:00.000Z",
"createdAt": "2026-04-10T12:00:00.000Z",
"updatedAt": "2026-04-10T12:00:00.000Z"
}Run checks locally:
cd frontend && npm run lint
cd frontend && npm run build
cd backend && npm run lint
cd backend && npm run buildThe same checks run in GitHub Actions CI. CI also runs npm audit for both packages.
Current checks:
- Frontend
lint: strict TypeScript check - Frontend
build: production build with Vite - Backend
lint: strict TypeScript check - Backend
build: NestJS build
The current demo flow is not a complete production authentication system.
Before production use, consider adding:
- Server-side verification of the source of user data
- Session binding to verified launch params
- Server-side VK API calls when needed
- Clear separation between demo user sync and real authorization logic
What is already included:
- Launch params are verified on the backend.
signis validated before the demo user sync flow uses VK context.- Auth actor is extracted into shared backend context.
- Frontend passes launch params explicitly instead of relying on implicit browser context.
- Keep the example user flow isolated from the app shell.
- Replace the starter screen with a navigation shell.
- Add a top-level backend health check.
- Add more reusable example modules on top of the current shell.
MIT. See LICENSE.
The maintainer is available for work, collaboration, and full-stack product development.
Telegram: @devflexpro
Email: devflex.pro@gmail.com