The Pokémon Showdown client is a browser-based application that powersDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/smogon/pokemon-showdown-client/llms.txt
Use this file to discover all available pages before exploring further.
play.pokemonshowdown.com. Contributing to it requires a build step — TypeScript and JSX source files are compiled down to browser-compatible JavaScript before you can test changes. Once your environment is set up, the iteration loop is fast: edit a source file, run node build, and reload the test client in your browser.
Prerequisites
Before cloning the repository, make sure the following tools are available on your system:Node.js v20+
The build system and test runner both require Node.js version 20 or later. Download from nodejs.org.
Git
Used to clone the repository and manage branches for pull requests. Any recent version of Git will work.
Setting Up the Repository
Run the initial build
The repository is not pre-built, so you must compile the source files before opening the test client. On Windows:On macOS and Linux you can also use the shorthand:This compiles all TypeScript and TSX source files from
play.pokemonshowdown.com/src/ into the play.pokemonshowdown.com/js/ output directory.Open the test client
Open
testclient-old.html (stable client) or testclient-new.html (beta Preact rewrite) in your browser. No local server is required for basic testing.The new Preact client is available at
testclient-new.html and mirrors the live beta at https://play.pokemonshowdown.com/beta. Prefer this file if you are contributing to the rewritten client.Configure a test key (recommended)
By default, logging in on the test client requires copy-pasting session data. For frequent reloads, create Replace
config/testclient-key.js with the following content:'sid' with the actual value of your sid cookie, which you can retrieve from:Build Commands
All scripts are defined inpackage.json. The primary entry point is node build, which performs an incremental compile using the custom build-tools/compiler.js wrapper around Babel.
The Build System
The build system lives inbuild-tools/compiler.js — a lightweight wrapper around @babel/core that adds incremental compilation on top of what babel-cli provides. It reads .babelrc for its plugin configuration and writes compiled output alongside source maps.
Key behaviours:
- Incremental by default — files are skipped if the source
ctimeis older than the destinationctime, making typical rebuilds fast. - Source maps —
.mapfiles are written alongside compiled.jsfiles so browser DevTools can map errors back to TypeScript source. - Concatenation — multiple source files can be combined into a single output bundle with a merged source map.
play.pokemonshowdown.com/js/ and related subdirectories (replay.pokemonshowdown.com/, teams.pokemonshowdown.com/).
Running Tests
The test suite is run by Mocha and lives in thetest/ directory:
| File | What it tests |
|---|---|
test/battle.test.js | Battle simulation logic |
test/ev-guesser.test.js | EV guesser heuristics |
test/ev-optimizer.test.js | EV optimizer output |
npm run test command combines all checks in the correct order:
tsc is run with noEmit: true (see tsconfig.json) — it performs type-checking only and does not produce output files. Babel handles the actual compilation.Connecting to Other Servers
You can point the test client at any Pokémon Showdown server by appending?~~host:port to the URL:
Code Ownership
TheCODEOWNERS file designates specific reviewers for certain parts of the codebase. Pull requests touching these paths will automatically request a review from the listed maintainers:
CODEOWNERS breakdown
CODEOWNERS breakdown
| Path | Owner |
|---|---|
play.pokemonshowdown.com/src/battle-animations-moves.ts | @KrisXV |
play.pokemonshowdown.com/src/battle-animations.ts | @KrisXV |
teams.pokemonshowdown.com/**/* | @mia-pi-git |
Architecture Overview
The client loads in four phases to balance startup speed with feature availability:Phase 1 — Background
Phase 1 — Background
client.css— basic stylingclient-core.ts— background model and view
Phase 2 — Basic UI
Phase 2 — Basic UI
client-main.ts— Prefs, Teams, User, Room, and PS modelsclient-connection.ts— server connection via SockJSpanel-mainmenu.tsx,panel-rooms.tsx,panels.tsx— URL router, global listeners, and main view
Phase 3 — Lightweight Panels
Phase 3 — Lightweight Panels
panel-chat.tsx— chat panelpanel-ladder.tsx— ladder panel
Phase 4 — Heavyweight Panels (on-demand)
Phase 4 — Heavyweight Panels (on-demand)
Loaded only when the user opens a battle or the teambuilder:
panel-battle.tsx,panel-teambuilder.tsxbattle-dex.ts,battle.ts- jQuery (loaded here, not earlier)
Avoid using jQuery in Phase 1–3 files. Interact with the DOM directly, being careful not to use APIs that crash IE9.
