Platform: AWS Lambda + CloudFront + S3 | Runtime: Node.js 20.x on ARM64 | Not supported: PHP, WebSockets, native modules without layers, persistent processes
Architecture
- Static assets are built and uploaded to S3, served via CloudFront CDN (global edge locations)
- Automatic HTTPS with wildcard certificate
- URL rewriting for clean routes (
/about→/about/index.html) - Cache: HTML 1 min, CSS/JS 5 min
- Each API route becomes a Lambda function with its own URL
- SSR pages are bundled with the server runtime
Resource Limits
Do’s and Don’ts
- Do
- Don't
- Use pure JavaScript packages —
bcryptjs,pg(pure mode),josefor JWT - Keep functions small — split large APIs into separate files for faster cold starts
- Use environment variables — store secrets in Hiveku’s env vars, not in code
- Optimize bundle size — use dynamic imports, tree-shaking, avoid bundling dev deps
- Use S3 for large files — generate presigned URLs for uploads over 6MB
- Return proper status codes — use 200, 201, 400, 401, 404, 500 appropriately
- Set cache headers — use Cache-Control for static responses
- Handle cold starts — initialize DB connections outside the handler
API Routes
Where to Place API Files
Hiveku auto-detects API routes from these directories:File to URL Mapping
API Handler Formats
Hiveku supports two function formats — use whichever you prefer:- Web API Format (Recommended)
- AWS Lambda Format
Modern format, similar to Next.js/Vercel Edge Functions:
hiveku.json Configuration
Create ahiveku.json in your project root to customize deployment:
Advanced Features
Lambda Layers
Auto-provisioned layers for native dependencies. These packages just work when you add the layer:sharp bcrypt argon2 canvas prisma ffmpeg puppeteer
Scheduled Functions (Cron)
Add a@schedule comment or put files in a cron/ directory:
cron(min hour day-of-month month day-of-week year)
Rate format:
rate(5 minutes), rate(1 hour), rate(1 day), rate(7 days)
Streaming Responses
SSE and chunked responses for AI apps. Auto-detected fromtext/event-stream content type:
Package Compatibility
- Works
- Needs Replacement
- Next.js Only
Code Patterns
Database Connection (Prisma)
Initialize the Prisma client outside the handler so connections are reused across Lambda invocations. Use connection pooling and keep-alive pings to avoid cold reconnect latency.JWT Authentication
Large File Upload (S3 Presigned URL)
Custom CORS Headers
Reusable Auth Middleware
Environment Variables
Auto-Injected Variables
These are available in every Lambda function automatically:Build-Time vs Runtime
NEXT_PUBLIC_*variables are bundled at build time and exposed to the browser- All other variables are available only at runtime, server-side only
Troubleshooting
Function timeout (30s limit)
Function timeout (30s limit)
Check if you’re hitting the 30s default timeout. Increase in
hiveku.json, or optimize your code. Database queries without connection pooling are a common cause.Bundle too large
Bundle too large
Use dynamic imports, check for accidentally bundled devDependencies, exclude large assets. Consider splitting into multiple functions.
Native module error
Native module error
You’re using a package with native bindings (
bcrypt, sharp, etc.). Switch to a pure JS alternative or request a Lambda Layer.CORS errors
CORS errors
Hiveku adds CORS headers automatically. If you still see errors, check your frontend is calling the correct URL and your API returns proper response format.
Environment variable undefined
Environment variable undefined
Make sure the variable is set in Hiveku dashboard.
NEXT_PUBLIC_* vars need a redeploy to take effect. Server-side vars are only available in Lambda, not the browser.Slow cold starts
Slow cold starts
Reduce bundle size, increase memory (more memory = faster CPU), minimize top-level imports. Consider keeping functions warm with scheduled pings.
Too many database connections
Too many database connections
Lambda can scale to many instances. Use a connection pooler (Supabase, PlanetScale) or set your pool size to 1-2 connections per function.
Files disappear from /tmp
Files disappear from /tmp
Lambda
/tmp is ephemeral. Files may persist between invocations on the same instance but will be cleared. Use S3 for persistent storage.