Skip to content

janmichek/playful-by-smarlify

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

91 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Playful.Smarlify.co ๐ŸŽฎ

A modern gaming hub featuring free online games built with Next.js 14, TypeScript, and Tailwind CSS. Play Traffic Run, Crossy Road, Space Shooter, and more!

๐ŸŽฎ Featured Games

  • Crossy Road - Endless runner with obstacles and coin collection (React Three Fiber, Zustand)
  • Traffic Run - High-speed 2.5D racing through busy traffic (Three.js, WebGL)
  • Space Shooter - Classic 2D space shooter defending Earth from aliens (WebGL, Vanilla JS)
  • Crazy Vacuum 3D - Coming soon! 3D vacuum cleaning adventure (Unity 3D)

โœจ Features

  • Modern Design: Glassmorphism UI with particle background effects
  • Game Embedding: Full-screen iframe integration for seamless gameplay
  • Share Functionality: Easy game sharing with copy-to-clipboard
  • Responsive Layout: Optimized for mobile, tablet, and desktop
  • SEO Optimized: Complete meta tags, OpenGraph, structured data
  • Analytics Tracking: Comprehensive game play tracking with localStorage persistence

๐Ÿ› ๏ธ Tech Stack

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Icons: Lucide React
  • Deployment: Heroku (heroku-24 stack)

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 22+ (LTS recommended)
  • npm, yarn, or bun

Installation

# Navigate to the project
cd _Playful

# Install dependencies
npm install

# Start development server
npm run dev

Open http://localhost:3000 to see the gaming hub.

Building for Production

# Build the project
npm run build

# Start production server
npm start

๐Ÿ“ˆ Analytics & Event Tracking

Comprehensive game analytics with localStorage persistence to track user engagement:

Tracked Events

  1. play_game - Tracks each game play instance

    • Parameters: game_name, timestamp
    • Example: play_game({ game_name: "Crossy Road", timestamp: "2025-01-15T10:30:00Z" })
  2. game_played_total - Tracks cumulative play count per user

    • Parameters: game_name, play_count, first_played, last_played
    • Example: game_played_total({ game_name: "Traffic Run", play_count: 10, first_played: "2025-01-10T08:00:00Z", last_played: "2025-01-15T10:30:00Z" })
  3. game_card_click - Game card clicks on the home page

  4. game_play_click - Play button clicks

  5. share_button_click - Share button clicks

  6. copy_link_click - Copy link actions

  7. social_share_click - Social media shares

  8. github_link_click - GitHub repository link clicks

Analytics Implementation

The analytics system uses localStorage to persist play counts per user (not per session):

// src/lib/analytics.ts
export interface GameStats {
  [gameName: string]: {
    playCount: number;      // Total plays by this user
    lastPlayed: string;     // ISO timestamp of last play
    firstPlayed: string;    // ISO timestamp of first play
  };
}

// Track when a game is played
trackGamePlayed('Crossy Road');

// Get play count for a specific game
const count = getGamePlayCount('Traffic Run'); // Returns: 10

// Get total play count across all games
const total = getTotalPlayCount(); // Returns: 47

// Get most played game
const mostPlayed = getMostPlayedGame(); // Returns: { name: "Crossy Road", count: 23 }

Storage Format

Game statistics are stored in localStorage under the key playful_game_stats:

{
  "Crossy Road": {
    "playCount": 23,
    "lastPlayed": "2025-01-15T10:30:00.000Z",
    "firstPlayed": "2025-01-10T08:00:00.000Z"
  },
  "Traffic Run": {
    "playCount": 10,
    "lastPlayed": "2025-01-15T09:15:00.000Z",
    "firstPlayed": "2025-01-12T14:20:00.000Z"
  }
}

TypeScript Support

Global type declarations in src/types/global.d.ts:

declare global {
  interface Window {
    trackEvent?: (eventName: string, parameters?: Record<string, unknown>) => void;
  }
}

Analytics Setup

  • Google Analytics 4: Event tracking with custom parameters
  • GTM (Google Tag Manager): Tag management for analytics
  • localStorage: Persistent play count tracking per user
  • Event Parameters: Rich metadata including timestamps, play counts, and game names

๐ŸŽจ Project Structure

_Playful/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ [game]/page.tsx      # Dynamic game pages
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx            # Root layout with SEO
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx              # Home page with game grid
โ”‚   โ”‚   โ””โ”€โ”€ cookies/page.tsx      # Cookie policy
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ GameCard.tsx          # Game card component
โ”‚   โ”‚   โ”œโ”€โ”€ GameIframe.tsx        # Game iframe with analytics
โ”‚   โ”‚   โ”œโ”€โ”€ ShareButton.tsx       # Share functionality
โ”‚   โ”‚   โ””โ”€โ”€ ParticleBackground.tsx
โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ””โ”€โ”€ games.ts              # Game definitions
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ analytics.ts          # Game analytics utilities โญ NEW
โ”‚   โ”‚   โ””โ”€โ”€ seo.ts                # SEO configuration
โ”‚   โ””โ”€โ”€ types/
โ”‚       โ”œโ”€โ”€ index.ts              # TypeScript types
โ”‚       โ””โ”€โ”€ global.d.ts           # Global type declarations
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ game-assets/              # Game thumbnails
โ”œโ”€โ”€ server.js                     # Express server for Heroku
โ””โ”€โ”€ package.json

๐ŸŒ Deployment

Heroku Deployment

The app is deployed on Heroku with Next.js static export:

# Deploy to Heroku
git push heroku main

Heroku Configuration:

  • Runtime: Node.js 22.x
  • Stack: heroku-24
  • Build: Next.js static export
  • Server: Express.js serving from out/ folder

Environment Variables

No environment variables required for basic functionality. Add GA4/GTM tracking IDs for analytics.

๐Ÿ”— Related Projects

๐Ÿ“ž Contact & Support

๐ŸŽฏ Roadmap

  • Leaderboard system with global high scores
  • User accounts and achievements
  • More games (Crazy Vacuum 3D, Puzzle games)
  • Mobile app versions (React Native)
  • Multiplayer support

๐Ÿ“‹ Development Status

Production-ready with active development ๐ŸŽ‰

โœ… Completed (2025)

  • โœ… Next.js 14 migration from Vite
  • โœ… SEO optimization with structured data
  • โœ… Game analytics with localStorage persistence โญ NEW
  • โœ… Share functionality with social media integration
  • โœ… Responsive design for all devices
  • โœ… Heroku deployment with Express server

๐Ÿšง In Progress

  • ๐Ÿšง Crazy Vacuum 3D game development
  • ๐Ÿšง Enhanced analytics dashboard
  • ๐Ÿšง User profiles and saved progress

Built with โค๏ธ by Smarlify | ยฉ 2025 All rights reserved

Free online games - play, have fun!

About

Playful by Smarlify - Gaming Hub

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 89.8%
  • CSS 5.4%
  • HTML 3.6%
  • JavaScript 1.2%