← Back to Here To Slay

Here To Slay, part 9: the visual side and Electron

Why Here To Slay's client is a TypeScript web app inside Electron, what that choice costs and whether it's worth swapping for a tool made for games, like Godot or PixiJS.

#tecnico

Almost every post so far has been about the server: Kafka, monitoring, the rules engine. The part players actually see shows up in the screenshots, in the redesign from part 5 and in the executable from part 8, but it never got a post of its own. This post is about it: what the client is made of, why it doesn’t use a game engine and whether it’s worth changing that.

What the client is

The client is written in TypeScript with React, and Vite handles development and builds. To become a desktop app, it’s packaged with Electron, which bundles a Chromium browser and Node.js into an executable and opens the game inside it. The same code also runs straight in the browser.

The cards are HTML elements, the animations are done with CSS, Framer Motion and GSAP, sounds play through Howler, and the only truly “game” piece is the library that draws the 3D dice.

Why this choice

The strongest reason is that the server decides everything. Since part 2, the client receives the match state over WebSocket, shows it on screen and sends the player’s actions. It does some math to display things, like the odds of each roll and the animations that come from comparing two states, but no game rule runs on it. There’s no physics, no collisions and no game loop running all the time, which is where a game engine helps most. A turn-based card game is, to a large extent, an interface.

And much of that interface is menus: login, table list, waiting room, chat, settings, card inspector, three languages. It’s text, forms and lists, exactly what HTML and CSS do well.

What I had done right before also played a part. In July 2025, for a Computer Networks course, I had built Pokémon UFES Crater, a multiplayer game with a React and Vite client talking over WebSocket to a Java server. When Here To Slay started, in September, it was born with that same combination.

Electron was there from the very first commit, which already had a script to build the Windows executable. From the start, then, the plan was a desktop app, not a website.

What Electron costs

Electron solves a real problem: turning a web app into a desktop app for Windows and Mac without rewriting anything. But it charges a lot for it, and not only in my project. The criticisms below are well known:

  • Size. Every Electron app ships its own Chromium and its own Node.js. That’s why, as I mentioned in part 8, almost none of Here To Slay’s executable is the game itself.
  • Memory. Since it’s a whole browser, each window opens several processes, and memory use ends up well above an equivalent native app.
  • Security. A web page with access to the system has to be configured carefully, and the security rules sometimes catch you off guard. That’s how the fonts loaded from the internet got blocked in the executable, and the class symbols simply didn’t show up.
  • Updates. Keeping everyone on the latest version means setting up an update system of your own. Until that exists, everyone keeps the version they downloaded, and that’s why the server got a minimum client version: an old client can’t log in and gets the link to the new version instead.

There are alternatives that tackle part of this without changing technology. The best known is Tauri, which uses the browser that already comes with the system (WebView2 on Windows and WebKit on Mac) instead of shipping a Chromium. Apps get much smaller, but the memory gain varies a lot, and each system ends up drawing the game with a different browser, which brings its own problems.

What if I switched to a game tool?

It’s a question I ask myself whenever I want a fancier animation and CSS starts fighting me. The good news is that the architecture helps: since all the logic is on the server, a new client would only need to speak the same protocol. Kafka, the rules and the card catalog would stay the same.

The bad news is that I’d have to rewrite the entire client, and some parts would be more work than they seem:

  • The protocol has no formal contract. Messages are JSON built by hand on the server, and the types only exist in the client’s TypeScript. In another language, I’d have to rediscover every field.
  • Some data only exists in the client, like the card and interface texts in three languages and the odds calculation for each roll.
  • Animations are inferred. As I explained in part 5, the server only sends the state of the table, and the client compares the new state with the previous one to figure out what happened. All of that logic would have to be redone.
  • Menus get worse. Everything that’s a form or a list in HTML today would have to be redone with the new tool’s interface system.

The options

A game library inside the current app. PixiJS is a 2D rendering library built on WebGL, and Phaser is a full game framework, both in JavaScript and TypeScript. On this path, login, tavern, waiting room and chat stay in React, and only the table and the game scenes start being drawn by the library. You get particles, effects and smoother animations without losing the browser, and the migration can happen one scene at a time, starting with the dice roll, for example. The downside is that Electron is still there, with all its weight.

Godot. It’s the engine that best fits a 2D card game: it’s free, open source, has WebSocket support and an interface system good enough for the menus. It exports to Windows, Mac, Linux, Android and iOS without shipping a browser. The browser version has improved a lot in recent releases, which started working without features Safari didn’t support, but it’s still more limited than the others. The cost is the highest of all: a new language, a new tool and the client rewritten from scratch.

Other engines. There are options like Defold, light and focused on 2D, Flutter with Flame, which makes more sense when the “app” weighs more than the “game”, and Unity, which is the most mature of all, but too heavy for a card game like this one.

Is it worth it?

Today, for me, it’s not worth switching everything. What the game needs most right now are the tweaks that come out of test matches, and rewriting the client would stop that for months. The current technology isn’t preventing anything important from happening.

What is worth it is preparing the ground, because it helps whichever path I choose later:

  • writing a contract for the messages between the client and the server;
  • moving the card and interface texts out of the code and into data files any client can read.

With that done, the most likely step is the most gradual one: putting a library like PixiJS only on the table, where animations matter most.