This is the new Svelte-based frontend for the mytoken server, replacing the legacy Mustache templates.
- SvelteKit 2 - Modern web framework with SSG support
- TypeScript - Type-safe JavaScript
- Bootstrap 5 - CSS framework
- Vite - Fast build tool
- Node.js 18+ (22+ recommended)
- npm 9+
cd frontend
npm installnpm run devThe dev server runs at http://localhost:5173 and proxies API requests to http://localhost:8000 (the Go backend).
npm run checknpm run buildThe built files are output to frontend/build/.
Note: The
internal/server/spa/dist/directory is gitignored. The CI pipeline automatically builds the frontend and includes it in the release artifacts. For local development, use./scripts/build-frontend.shto build and copy the frontend to the correct location.
Use the provided script to build the frontend and copy it to the Go embed directory:
./scripts/build-frontend.shThis will:
- Build the Svelte frontend
- Copy the built files to
internal/server/spa/dist/ - The files will be embedded in the Go binary during compilation
Add the following to your config.yaml:
features:
web_interface:
enabled: true
use_spa: trueWhen use_spa is true and the SPA distribution is available, the server will serve the Svelte SPA instead of the Mustache templates.
- If
use_spaisfalseor the SPA files are not available, the server falls back to the original Mustache templates - API routes (
/api/*) are always handled by the Go backend - The SPA handles client-side routing for all other paths
frontend/
├── src/
│ ├── app.html # HTML shell
│ ├── app.d.ts # TypeScript declarations
│ ├── routes/ # SvelteKit routes (pages)
│ │ ├── +layout.svelte # Main layout
│ │ ├── +page.svelte # Home page
│ │ ├── settings/ # Settings pages
│ │ ├── consent/ # Consent page
│ │ └── ...
│ └── lib/ # Shared code
│ ├── api/ # API client
│ ├── components/ # Svelte components
│ ├── stores/ # Svelte stores
│ ├── types/ # TypeScript types
│ └── utils/ # Utility functions
├── static/ # Static assets
├── package.json
├── svelte.config.js
├── vite.config.ts
└── tsconfig.json
TagPill- Display/remove tagsCopyButton- Copy to clipboard buttonLoadingSpinner- Loading indicatorCollapsibleSection- Expandable sectionsErrorModal- Error display modalToastContainer- Toast notifications
CapabilityTree- Capability selection treeRestrictionsEditor- Restriction clause editorRotationSettings- Token rotation settings
CreateMytoken- Create new mytoken formTokenInfo- Token introspection displayTokenList- List of user's tokensCreateAccessToken- Get access token formTransferCode- Create/redeem transfer codes
The frontend communicates with the Go backend via the same REST API used by the original frontend. The API client in src/lib/api/client.ts provides typed methods for all endpoints:
- Token operations (create, introspect, revoke)
- User settings (grants, SSH keys, email)
- Notifications (calendars, subscriptions)
- Transfer codes
The Svelte frontend is designed as a drop-in replacement:
- Same Bootstrap styling (upgraded to v5)
- Same API endpoints
- Same authentication flow
- Configurable via
use_spaoption
Both frontends can coexist - set use_spa: false to use the original Mustache templates.