Setup
This guide walks you from zero to a running Klippy editor locally, then to a production build. It also covers Windows‑specific steps and common issues you may run into (and how to fix them).
1) Prerequisites
- Node.js 18–20 (recommended: 20 LTS). Use a version manager:
- macOS/Linux:
nvm—nvm install 20thennvm use 20 - Windows: nvm‑windows —
nvm install 20thennvm use 20
- macOS/Linux:
- Git (any recent version).
- Recommended: VS Code and the ESLint extension.
- Windows native build tools (only if you plan to run tests that compile native modules like
canvas): Install Visual Studio Build Toolswith the “Desktop development with C++” workload. Alternatively, use WSL2 (Ubuntu) where the Linux steps below apply directly.
2) Get the code
- Clone the repository:
git clone https://github.com/your-org/aivideoeditor.git cd aivideoeditor
Tip (Windows): Clone into a short path likeC:\\dev\\aivideoeditorto avoid path length issues. - Install dependencies:
npm install
3) Configure environment
Most features work without keys in development, but stock media and monitoring are disabled. Create a file named .env.local in the repository root with the following (fill as needed):
# Site & CORS (especially important for production) NEXT_PUBLIC_SITE_URL=http://localhost:3000 # ALLOWED_ORIGINS can include multiple, comma-separated ALLOWED_ORIGINS=http://localhost:3000 # Optional stock media (server-side only) PEXELS_API_KEY=your_pexels_api_key TENOR_API_KEY=your_tenor_api_key TENOR_CLIENT_KEY=clip-js MEME_API_KEY=your_meme_api_key # Optional: FFmpeg WASM controls NEXT_PUBLIC_FFMPEG_ALLOW_CDN=true NEXT_PUBLIC_FFMPEG_CDN_BASE=https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd # Monitoring (optional) NEXT_PUBLIC_SENTRY_DSN= SENTRY_AUTH_TOKEN= SENTRY_ORG= SENTRY_PROJECT=
- Keep API keys server‑side (no
NEXT_PUBLIC_prefix). Requests are proxied by Next.js. - In development, API origin checks are lenient; in production they are strict (see Troubleshooting).
4) Start the dev server
Pick the command for your OS/shell:
- macOS/Linux:
npm run dev:clean - Windows (PowerShell or CMD):
npm run dev:win - Windows (WSL2 or Git Bash):
npm run dev:cleanworks as on Linux.
Then open http://localhost:3000.
- macOS/Linux:
lsof -ti:3000 | xargs kill -9 - Windows (PowerShell):
netstat -ano | findstr :3000 taskkill /PID <PID_SHOWN_ABOVE> /F
5) Verify editor
- Go to
/projects→ “Create New Project”, then click a project to open the editor. - Drag a short MP4 or WebM into the Media panel, then onto the timeline.
- Open the Export modal from the header; FFmpeg may preload on first use.
6) Optional: Stock media
To enable Pexels/Tenor/Meme browsing, set keys in .env.local (see above), then restart the dev server. These features proxy via /api/pexels/*, /api/tenor/*, and /api/meme/*.
7) Tests and E2E
- Unit tests:
npm test - E2E (Playwright): In one terminal run
npm run dev:clean, then in another:npx playwright install npm run test:e2e
Windows tip: If browsers fail to install, run PowerShell as Administrator or usenpx playwright install --with-depsin WSL.
8) Build for production
- Ensure
.env/.env.localcontains production values (especiallyNEXT_PUBLIC_SITE_URLandALLOWED_ORIGINS). - Build:
npm run build - Start:
npm start→ open your deployed URL.
Windows notes
- Use
npm run dev:win(no Linux tools required). If you prefer Bash, use Git Bash or WSL2 and the Linux command. - If
npm installfails oncanvasor other native deps, install Visual Studio Build Tools, then retry. Or run tests from WSL2. - Path length: Clone into a short path (e.g.,
C:\\dev). - Port conflicts: Use
netstat -ano | findstr :3000andtaskkill /PID <PID> /F.
Troubleshooting
403 “Unauthorized origin” (Meme/Tenor APIs)
In production, API routes validate Origin/Referer. Set NEXT_PUBLIC_SITE_URL to your public URL and ensureALLOWED_ORIGINS includes it. For Electron or file:// contexts, you can enable ALLOW_NULL_ORIGIN=true.
500 “API key not configured”
Add the relevant key (e.g., PEXELS_API_KEY, TENOR_API_KEY, MEME_API_KEY) to .env.local and restart.
FFmpeg fails to load or is slow
Check network panel for /wasm/ffmpeg-core.* with MIME application/wasm. Allow CDN fallback viaNEXT_PUBLIC_FFMPEG_ALLOW_CDN=true or ensure those files are served by your host.
Images/GIFs from Tenor don’t load
Thumbnails load directly from Tenor; media downloads go through /api/tenor/proxy. Ensure your CSP allowstenor.googleapis.com and *.tenor.com (middleware already configures this by default).
TypeScript / Node version mismatch
Use Node 18–20. If you’re on Node 22 and see Next/React errors, switch via nvm to 20 LTS.