- Surge Web Dashboard (formerly YASD) is a React 19 single-page app for controlling Surge instances through the Surge HTTP API.
- The app authenticates against a selected Surge host, then sends API traffic to that host's
/v1endpoints. - Remembered profiles and language/theme preferences are stored locally in the browser.
- Node
24is the expected runtime (.node-versionis24,package.jsonrequires>=24 <25). - Package manager:
pnpm(packageManager: pnpm@10.32.1). - Vite Plus (
vp) powers the dev server, linting, formatting, and tests. - Path alias:
@/*maps tosrc/*. - TypeScript is strict and uses Emotion's JSX runtime (
jsxImportSource: @emotion/react).
pnpm start # dev server
pnpm start:profile # dev server with profiling enabled
pnpm lint # type-aware lint
pnpm lint:fix # auto-fix lint issues
pnpm test:types # TypeScript typecheck
pnpm test # run Vitest once
pnpm test -- src/path/to.spec.ts
pnpm test:watch # watch mode
pnpm test:coverage # coverage report
pnpm verify-translation # ensure zh keys match en baseline
pnpm build # Vercel-style production build with service worker
pnpm build:release # CI release build + tarball bundle
pnpm build:surge # Surge built-in bundle under /websrc/index.tsxis the browser entrypoint: it loads global styles, initializes i18n, renders the router, and conditionally registers the service worker.src/router/router.tsxwraps the route tree withAppContainerandApp, then creates either a browser router or hash router based onVITE_HASH_ROUTER.src/routes.tsxis the route map. Most feature pages are lazy-loaded;routeOptionscontrol fullscreen pages and safe-area behavior.AppContainerwires Redux, Helmet, theme state, UI confirmation dialogs, safe-area support, and bootstrap-time initialization.App.tsxowns app-level SWR config, the page layout shell, traffic polling hookup, network failure modal, and version update checks.
- Redux in
src/storeis intentionally small:history: remembered Surge profiles from local storageprofile: the currently selected Surge targettraffic: rolling traffic stats used by the dashboard charts
profileActions.updateis the key handoff point: it callssetServer(...)insrc/utils/fetcher.ts, which reconfigures the shared Axios client with the selected host, port, TLS mode, andx-keyheader.- Most server reads use SWR on top of that shared Axios client (
src/utils/fetcher.ts,src/data/api.ts, plus page-local hooks). src/bootstrap/Bootstrap.tsxrestores remembered profile history and last-used language before rendering the app.
src/pages/*contains route-level screens: Landing, Home, Policies, Requests, Traffic, Modules, Scripting, DNS, Devices, and Profiles.src/components/*contains shared UI, providers, and cross-page building blocks.src/components/ui/*holds shadcn/ui-style primitives.src/types/index.tsis the central place for API response and domain types.
- The codebase uses a hybrid styling approach:
- Tailwind CSS v4 + shadcn tokens in
src/styles/shadcn.css - global CSS in
src/styles/global.css - Emotion
css/styledin many page and shared components
- Tailwind CSS v4 + shadcn tokens in
- When editing UI, match the surrounding style instead of forcing a single styling system.
- i18n lives under
src/i18nand lazy-loads locale JSON files. - English (
src/i18n/en/translation.json) is the baseline;scripts/verify-translations.mjschecks thatzhcontains every key fromen. - If you add or rename translation keys, run
pnpm verify-translation.
scripts/build.mjsdrives release builds and post-processing.- Important env toggles used by the app/build:
VITE_HASH_ROUTERVITE_RUN_IN_SURGEVITE_URL_PATH_PREFIXVITE_USE_SWVITE_PROFILE- local-dev connection helpers:
VITE_PROTOCOL,VITE_HOST,VITE_PORT
pnpm buildtargets the standalone/Vercel deployment flow.pnpm build:releaseandpnpm build:surgeswitch to hash-routing and bundle artifacts for release distribution.
- GitHub Actions runs on Node 24 and currently executes
pnpm build,pnpm verify-translation, andpnpm test. - Commit messages follow Angular-style commitlint rules with a 72-character header limit.
This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called vp. Vite+ is distinct from Vite, but it invokes Vite through vp dev and vp build.
vp is a global binary that handles the full development lifecycle. Run vp help to print a list of commands and vp <command> --help for information about a specific command.
- create - Create a new project from a template
- migrate - Migrate an existing project to Vite+
- config - Configure hooks and agent integration
- staged - Run linters on staged files
- install (
i) - Install dependencies - env - Manage Node.js versions
- dev - Run the development server
- check - Run format, lint, and TypeScript type checks
- lint - Lint code
- fmt - Format code
- test - Run tests
- run - Run monorepo tasks
- exec - Execute a command from local
node_modules/.bin - dlx - Execute a package binary without installing it as a dependency
- cache - Manage the task cache
- build - Build for production
- pack - Build libraries
- preview - Preview production build
Vite+ automatically detects and wraps the underlying package manager such as pnpm, npm, or Yarn through the packageManager field in package.json or package manager-specific lockfiles.
- add - Add packages to dependencies
- remove (
rm,un,uninstall) - Remove packages from dependencies - update (
up) - Update packages to latest versions - dedupe - Deduplicate dependencies
- outdated - Check for outdated packages
- list (
ls) - List installed packages - why (
explain) - Show why a package is installed - info (
view,show) - View package information from the registry - link (
ln) / unlink - Manage local package links - pm - Forward a command to the package manager
- upgrade - Update
vpitself to the latest version
These commands map to their corresponding tools. For example, vp dev --port 3000 runs Vite's dev server and works the same as Vite. vp test runs JavaScript tests through the bundled Vitest. The version of all tools can be checked using vp --version. This is useful when researching documentation, features, and bugs.
- Using the package manager directly: Do not use pnpm, npm, or Yarn directly. Vite+ can handle all package manager operations.
- Always use Vite commands to run tools: Don't attempt to run
vp vitestorvp oxlint. They do not exist. Usevp testandvp lintinstead. - Running scripts: Vite+ commands take precedence over
package.jsonscripts. If there is atestscript defined inscriptsthat conflicts with the built-invp testcommand, run it usingvp run test. - Do not install Vitest, Oxlint, Oxfmt, or tsdown directly: Vite+ wraps these tools. They must not be installed directly. You cannot upgrade these tools by installing their latest versions. Always use Vite+ commands.
- Use Vite+ wrappers for one-off binaries: Use
vp dlxinstead of package-manager-specificdlx/npxcommands. - Import JavaScript modules from
vite-plus: Instead of importing fromviteorvitest, all modules should be imported from the project'svite-plusdependency. For example,import { defineConfig } from 'vite-plus';orimport { expect, test, vi } from 'vite-plus/test';. You must not installvitestto import test utilities. - Type-Aware Linting: There is no need to install
oxlint-tsgolint,vp lint --type-awareworks out of the box.
- Run
vp installafter pulling remote changes and before getting started. - Run
vp checkandvp testto validate changes.