A Local First Next.js application to track the play time of players on a team - with TinyBase for state management and real-time synchronization.
🚀 Live Demo: https://game-time-plus-next.vercel.app
Game-Time-Plus-Demo.2.mp4
This project is set up as a monorepo with the following packages:
packages/game-time-plus
- The main Next.js applicationpackages/tinybase-server
- WebSocket server for TinyBase synchronization
This project uses TinyBase for managing team and player data with both local storage persistence and real-time synchronization. The implementation includes:
- A TinyBase mergeable store for teams and players data
- Local storage persistence for offline capability
- WebSocket synchronization for real-time collaboration
- Custom React hooks for easy integration with components
packages/game-time-plus/src/hooks/useTeamsStore.ts
- Custom React hook for using the teams store with local persistencepackages/game-time-plus/src/components/Store.tsx
- Provider component for TinyBase store with WebSocket synchronizationpackages/game-time-plus/src/components/TeamNameForm.tsx
- Example component using the TinyBase storepackages/game-time-plus/src/components/Players.tsx
- Component for managing player datapackages/tinybase-server/ws-server.ts
- WebSocket server implementation for TinyBase synchronization
The application demonstrates how to use TinyBase to:
- Add and delete team names with city information
- Navigate to team-specific pages
- Persist data between page refreshes using localStorage
- Synchronize data in real-time across multiple clients
- Manage player information for teams
Game Time Plus includes a powerful API for accessing and manipulating team and player data.
The API supports complex queries to filter and retrieve specific data:
First, install dependencies and run the development server:
# Install dependencies
pnpm install
# Start the development server
pnpm dev
Open http://localhost:3000 with your browser to see the result.
The application requires the following environment variables:
# TinyBase WebSocket server URL
NEXT_PUBLIC_TINYBASE_SERVER_URL=ws://localhost:8787
An example .env
file is provided in packages/game-time-plus/.env.example
.
To learn more about the technologies used in this project:
The Next.js application can be deployed on Vercel and the TinyBase server can be deployed on Cloudflare Workers.