casino-slot-machine-svelte Svelte Themes

Casino Slot Machine Svelte

Svelte 5 Casino Slot Machine

🎰 SvelteKit Slot Machine β€” "The House Always Wins"

A modern, fully reactive slot machine built with Svelte 5 (runes) and TypeScript, deployed on Vercel.
This project demonstrates strong front-end architecture, server logic separation, and clean state management practices.


🧱 Tech Stack

Frontend:

  • ⚑ Svelte 5 + TypeScript
  • 🎨 Modern responsive UI with smooth animations
  • 🧩 Runes-based reactivity ($state)
  • πŸ’Ύ Session persistence with sessionStorage

Backend:

  • πŸ” SvelteKit API Routes (/api/start, /api/roll, /api/cashout)
  • 🧠 In-memory session management (sessions.ts)
  • 🎰 Pure TypeScript logic for deterministic gameplay
  • ☁️ Ready for edge deployment (Vercel Functions)

πŸ—‚οΈ Project Structure

src/
β”œβ”€β”€ lib/
β”‚   └── server/
β”‚       └── sessions.ts          # Session store and helpers
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ +page.svelte             # Main slot game UI
β”‚   └── api/
β”‚       β”œβ”€β”€ start/+server.ts     # Start or resume a session
β”‚       β”œβ”€β”€ roll/+server.ts      # Handle spin logic
β”‚       └── cashout/+server.ts   # Handle cashout endpoint

🧩 Features

  • 🎯 Auto session resume β€” Player can refresh and continue game
  • 🎰 Animated slot reels with staged symbol reveal
  • πŸ’° Cashout logic β€” Credits can be redeemed if eligible
  • πŸ’€ Game-over state when credits hit zero
  • 🧠 Smart session handling β€” Sessions stored in memory for quick access
  • πŸ” Replay-ready β€” Easily start a new session after cashout

βš™οΈ Running Locally

# 1️⃣ Install dependencies
npm install

# 2️⃣ Run the dev server
npm run dev

# 3️⃣ Open in your browser
http://localhost:5173

πŸš€ Deployment

Deployed via Vercel β€” uses SvelteKit’s native serverless adapters.
Each API route runs independently as a lightweight edge function.


πŸ’‘ Design & Code Practices

  • 🧩 Modular architecture separating UI, state, and API logic
  • πŸ’¬ Strongly typed interfaces for all backend routes
  • ⚑ Optimized for reactivity and instant feedback
  • 🎨 Styled with modern gradients, rounded UI, and micro-interactions
  • 🧠 Focus on readability, maintainability, and fun

πŸ§‘β€πŸ’» Author

Rafael Dev
Independent Bilingual Developer β€” Full Stack / Frontend / Creative Technologist
🌎 Focused on remote-first, product-driven environments


🏁 Summary

A playful yet technically solid demonstration of SvelteKit’s full-stack power β€”
built with modern TypeScript, best practices, and developer joy in mind.

Top categories

Loading Svelte Themes