← Technology Archive

Historical archive

Building a Real-Time Game with Vue 3, Egg.js, and TypeScript

A small learning project that combines a Vue 3 client, an Egg.js server, TypeScript, and Socket.IO for real-time game communication.

This practice project was built to learn Egg.js and Vue 3. TypeScript was included to make the client and server code more explicit and consistent.

Original preview and source

The original client was published at game.artifact4u.com and the server at ws.game.artifact4u.com. Those historical preview services may no longer be online.

The source code remains available on GitHub:

sschen-cn/vue3-eggjs-ts-realtime-game

Animated preview of the real-time game

Main dependencies

Socket.IO

Socket.IO is not simply a raw WebSocket connection. It uses its own higher-level protocol, can use WebSocket as a transport, and provides additional connection behavior. Both the server and client must use compatible Socket.IO libraries.

This project used egg-socket.io on the server and the Socket.IO client with TypeScript definitions in the browser.

TypeScript

Vue 3 itself was rewritten in TypeScript, so TypeScript integration on the Vue side felt natural. At the time of the experiment, the Egg.js TypeScript developer experience required more manual work.

Dependency names and APIs in this 2020 project may differ from current Socket.IO, Vue, and Egg.js releases.