Remote Workspaces
JavaScript / React Example
A ready-to-run remote workspace template for modern React & TypeScript projects
Spin up a fully-featured JavaScript remote workspace in seconds.
This example uses React + TypeScript + Vite but you can adapt it to any Node-based stack.
1 · Complete devcontainer.json
Save the file below to .devcontainer/devcontainer.json
in your repository or upload it while creating the workspace.
What each setting does
Marker | Field | Purpose |
---|---|---|
➊ name | Display name in Factory UI. | |
➋ image | Starts from a Node 20 image that already includes git , curl , and common JS tooling. | |
➌ postCreateCommand | Runs once after the container is built; installs packages via pnpm (fastest). Replace with npm install if preferred. | |
➍ forwardPorts | Exposes Vite’s default dev server on port 5173 so Factory shows a live preview link. | |
➎ settings | VS Code-style settings scoped inside the remote workspace—keeps local editor prefs untouched. | |
➏ extensions | Auto-installs linting/formatting helpers for every collaborator—no manual setup. | |
➐ postAttachCommand | Runs every time someone connects; perfect for lightweight checks like unit tests. |
2 · Common Commands
Once the workspace is attached to your session, open the Terminal toolkit and try:
Task | Command |
---|---|
Start dev server | pnpm dev (or npm run dev ) |
Run unit tests | pnpm test |
Execute linter | pnpm lint |
Build production bundle | pnpm build |
Install a package | pnpm add axios |
Upgrade deps | pnpm up --latest |
Check TypeScript types | pnpm type-check |
All output streams back into chat; no local Node install required.
3 · JavaScript / TypeScript Best Practices in Remote Workspaces
- Use pnpm + corepack – Faster installs and deterministic lockfiles (
corepack enable && pnpm install
). - Cache build tools – Move heavy installs (Playwright, Cypress) to a Dockerfile stage to speed up rebuilds.
- Lock Node version – Pin to a major/minor (
20-bullseye
) so everyone runs the same runtime. - Keep
forwardPorts
in sync – If you switch to Next.js (port 3000) or Remix (port 5173), update the list. - Run type checks on attach – Catch errors early with
postAttachCommand: "pnpm type-check"
. - Share VS Code extensions – List ESLint/Prettier so new teammates are productive from minute one.
- Avoid global installs – Use workspace scripts; they’re already on the PATH inside the remote workspace.
- Test locally –
devcontainer up
before committing to ensure the image builds without Factory-specific magic.
Next steps
- Customize the image by adding a
Dockerfile
for Playwright, Prisma, etc. - Add Secrets (e.g.,
API_KEY
) in Integrations → Secrets and reference them in your devcontainer. - Rebuild the workspace after any devcontainer change to pick up new tooling.