Deployment Overview
Stormkit leverages AWS infrastructure for deployment. Each deployment can contain three types of files:- Static files - CDN-served assets (HTML, CSS, JS, images)
- Server files - Server-side rendering functions
- API files - Serverless API endpoints
Folder Structure
Stormkit looks for a specific folder structure to determine what to deploy.Default Structure
By default, Stormkit looks for a.stormkit subfolder:
Custom Output Folder
You can specify a different output folder in Environment > Config > Output folder. If you specify a custom folder, Stormkit validates the same structure:Fallback Folders
If no.stormkit folder exists and no output folder is specified, Stormkit checks these common folders in order:
outoutputdistbuildpublic
Static Files
All files under.stormkit/public (or the configured output folder) are deployed to S3 and served by CloudFront CDN.
Example Static Structure
https://your-app.com/index.htmlhttps://your-app.com/assets/app.csshttps://your-app.com/images/logo.png
Content Types
Stormkit automatically sets appropriateContent-Type headers based on file extensions:
.html→text/html.css→text/css.js,.mjs→application/javascript.json→application/json.png→image/png.jpg,.jpeg→image/jpeg
Server Files
Server files enable server-side rendering (SSR) and are deployed as AWS Lambda functions.Entry Point Detection
In theserver subfolder, Stormkit looks for an entry file in this order:
index.jsindex.mjsindex.cjsserver.jsserver.mjsserver.cjs
Handler Export
The entry file must export a function namedhandler wrapped by the @stormkit/serverless helper:
.stormkit/server/index.js
Request/Response Objects
The handler receives standard Node.jshttp.IncomingMessage and http.ServerResponse objects:
Dependencies
Stormkit automatically bundles Node.js dependencies found in your server code. Dependencies are detected by scanning forimport and require statements.
To include additional dependencies:
package.json
API Files
API files follow file-system routing, similar to Next.js API routes or Vercel functions.File System Routing
Each file in theapi folder becomes an endpoint:
Handler Export
Each API file exports a default function:.stormkit/api/hello.js
API functions don’t need the
serverless wrapper. Stormkit handles the wrapper automatically for API routes.Dynamic Routes
Use bracket notation for dynamic parameters:.stormkit/api/users/[id].js
/api/users/123 will have req.params.id === "123".
Auto-Building API Folder
If you have anapi folder in your repository root, Stormkit automatically builds and deploys it to .stormkit/api.
To disable auto-building:
Build Process
The complete build process follows these steps:1
Repository Clone
Runner clones your repository at the specified branch and commit.
2
Runtime Installation
Installs required runtimes (Node.js, Go, etc.) using mise based on version files.
3
Dependency Installation
Runs package manager install command (
npm install, yarn, pnpm install, etc.).4
Build Command
Executes your configured build command with environment variables.
5
API Auto-Build
If an
api folder exists, automatically builds and transpiles it.6
Artifact Bundling
Identifies static, server, and API folders. Bundles required dependencies.
7
Compression
Creates zip files for each artifact type (client.zip, server.zip, api.zip).
8
Upload
Uploads artifacts to S3 and configures Lambda functions.
Deployment Artifacts
Each deployment creates the following artifacts:Client Zip
Contains all static files from thepublic folder(s).
Included:
- HTML files
- CSS files
- JavaScript bundles
- Images and fonts
- Any static assets
Server Zip
Contains server-side code and dependencies. Included:- Entry file (index.js, server.js, etc.)
- Bundled node_modules dependencies
- Server-side code and templates
API Zip
Contains API functions and dependencies. Included:- API route files
- Stormkit API wrapper (stormkit-api.mjs)
- Bundled node_modules dependencies
Example Deployment
Here’s a complete example of a React app with API:Repository Structure
Build Configuration
vite.config.ts
Deployment Result
Starter Template
Check out the React Starter Template to see a complete example with the correct.stormkit folder structure.
Related Documentation
Configuration
Configure output folders and build settings
Application Runtime
Run long-running server processes
Writing API
Complete guide to API functions
Troubleshooting
Fix common deployment issues