replit-extension
Building a Replit Extension
A Replit Extension is a React tool panel inside the Replit workspace, built on the Replit Extensions API (@replit/extensions). Source lives in integrations/<name>/. Thin frontend over your own backend — useful for "announce a shipped Repl" flows. Playbook: itsryanarmani/scripts scripts/replit-extension/README.md.
The trap that cascades: over-typed result wrappers
A local helper that asserts a client method returns exactly { data: T[] } — when the SDK actually returns { data?: T[] | undefined } or T[] | { data: T[] } — produces a wall of TS2352 / TS2345 "not comparable / not assignable" errors that cascade through every caller. Fix the shape at the boundary: type the wrapper to the SDK's actual return (optional/union), and narrow with Array.isArray(x) ? x : x.data ?? [] at the call site. Don't paper it with any.
The other traps
import.meta.envuntyped — Vite + TS needssrc/vite-env.d.tswith thevite/clientreference (TS2339 otherwise).- Workspace panel, not a page — the extension mounts in Replit's tool dock; store the API key in the extension's own storage, per-user.
- Manifest/config declares the tool + permissions; a placeholder id runs in dev but not published.
Build path
- React panel on
@replit/extensions(New Post / Queue / Accounts commands map well);npm run build. - Compose/schedule a post via your API (
platformTypestring); list upcoming posts.