Welcome to the Betterflow contributor guide. Whether you’re fixing a bug, adding a feature, or improving the docs, this page covers everything from local setup through coding conventions and pull-request etiquette so you can contribute with confidence.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/betterspacx/app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before cloning the repo, make sure you have the following installed and ready:Node.js 18+
Required by Next.js 16 and the pnpm tool-chain. Check with
node -v.pnpm
The only supported package manager. A
preinstall hook blocks npm and Yarn.Git
Needed to clone, branch, and push your changes to GitHub.
TypeScript / React / Next.js
Working knowledge of all three is expected — the codebase uses all of them heavily.
Local Setup
Copy the environment file
Copy the example env file and fill in any optional services you need. Core editing features work without any configuration — only R2 asset storage and the screenshot API require values.
Start the development server
Coding Standards
Consistent code style keeps the codebase readable and reviews fast. The sections below are enforced by ESLint — runpnpm run lint at any time to check.
TypeScript
- Use TypeScript for all new code.
- Avoid
any. Useunknownif the type is genuinely not known at compile time. - Be explicit about function parameter and return types, even when inference would work.
React
- Use functional components with hooks — no class components.
- Prefer named exports over default exports for easier refactoring.
- Add the
'use client'directive to every component that uses browser APIs, event handlers, or Zustand. - Keep components single-purpose — split large components into focused sub-components.
Styling
Always use CSS theme variable utility classes. Never reach for literal color values.
| Use this ✅ | Avoid this ❌ |
|---|---|
bg-background | bg-white / bg-black |
text-foreground | text-neutral-900 |
bg-card | bg-gray-100 |
border-border | border-gray-200 |
bg-primary | #4168d0 (hex) |
app/globals.css. Adding a new token there makes it available to every component automatically.
File Naming
| File type | Convention | Example |
|---|---|---|
| React component | PascalCase.tsx | ShadowControls.tsx |
| Utility / helper | kebab-case.ts | export-utils.ts |
| TypeScript interface | PascalCase name | interface CanvasObject |
Linting
pnpm run lint before committing. The CI pipeline will fail on lint errors.
Common Tasks
The sections below walk through the most frequent contribution patterns with concrete file paths.Adding a new control panel
Adding a new control panel
Control panels live in
components/controls/. Each panel is a focused React component that reads and writes a single slice of Zustand state.- Create your component file:
- Wire it to the relevant Zustand store from
lib/store/index.ts:
-
Add it to the appropriate editor panel (
components/editor/editor-left-panel.tsxorcomponents/editor/unified-right-panel.tsx). -
Update TypeScript types in
types/if your control introduces new state shape.
Adding a browser mockup style
Adding a browser mockup style
Browser mockup frames share a single
BrowserToolbar component used by both the 2D HTML layer and the 3D overlay.- Add the toolbar variant inside
components/canvas/frames/BrowserToolbar.tsx. - The toolbar is consumed by both
HTMLMainImageLayer(2D) andFrame3DOverlay(3D) — no extra wiring needed for rendering. - Register the frame type in the
FrameConfigunion insideFrame3DOverlay.tsx:
- Add header height to
canvas-dimensions.tsso padding calculations are correct for the new frame:
- Add a preview card in
components/editor/sections/BrowserMockupSection.tsxso users can click to apply it.
Adding a new background
Adding a new background
All background definitions live in To add a new gradient, add its key to
lib/constants/backgrounds.ts. The BackgroundConfig type accepts 'gradient', 'solid', or 'image' as the type field.lib/constants/gradient-colors.ts and the CSS value will be picked up automatically by getBackgroundStyle(). If you need a new BackgroundType, update the BackgroundConfig type and the getBackgroundStyle / getBackgroundCSS switch statements.Adding an animation preset
Adding an animation preset
Presets are defined in When the user applies a preset to the timeline, always use
lib/animation/presets.ts. Each preset describes a named animation with one or more AnimationTrack objects that each hold an array of Keyframe values.clonePresetTracks() — this generates fresh unique IDs so multiple clips of the same preset can coexist:Modifying export logic
Modifying export logic
The export pipeline is split across several focused files in
The video export orchestrator lives at
lib/export/:| File | Responsibility |
|---|---|
export-service.ts | Image export — composites background, HTML canvas layers, and overlays |
ffmpeg-encoder.ts | FFmpeg WASM encoder for H.264 and GIF |
webcodecs-encoder.ts | Hardware-accelerated H.264 via WebCodecs API + mp4-muxer |
video-encoder.ts | MediaRecorder wrapper for native WebM |
export-utils.ts | Shared helpers (noise texture, OKLCH conversion, etc.) |
lib/export-slideshow-video.ts. To modify image quality or add a new export format, start in export-service.ts. To change video encoder behaviour or add a new encoder, edit the relevant encoder file and update the selection logic in lib/export-slideshow-video.ts.Submitting Changes
Branch naming
Conventional commits
Betterflow uses Conventional Commits. Your commit message should follow this format:| Type | When to use |
|---|---|
feat | New feature or capability |
fix | Bug fix |
refactor | Code change that neither fixes a bug nor adds a feature |
docs | Documentation changes only |
Pull request checklist
Before opening a PR, confirm every item below:Reviewers will not merge a PR that fails
build or lint. Run both locally first to save round-trips.-
pnpm run buildpasses with no errors -
pnpm run lintpasses with no warnings - Manually tested in the browser
- No
console.erroror unexpectedconsole.warnoutput - Follows the existing code style (see Coding Standards)
- PR description explains what changed, why, and how to test it
- Screenshots or a screen recording attached for any visual changes
Manual testing checklist
Run through this list before marking your PR ready for review:- Image upload — drag & drop and file picker
- Background changes — gradient, solid, and image types
- Device frames and border controls
- 3D perspective transforms
- Text and image overlays
- Animation presets and timeline playback
- Export — PNG, JPG, and at least one video format (MP4 or WebM)
- Copy to clipboard
- Aspect ratio changes
- Responsive layout at narrow viewport widths
Getting Help
GitHub Issues
Report bugs or request features. Include steps to reproduce, expected vs actual behaviour, browser/OS details, and any console errors.
GitHub Discussions
Ask questions, share ideas, or get feedback on a proposed approach before writing code.