This is a cloud function template. Write once, deploy to multiple platforms — Cloudflare, Deno Deploy, EdgeOne, Netlify, Vercel and more.
- Single codebase for multiple cloud platforms
- Few configuration deployment
- TypeScript support
- https://uni-function.deno.dev/
- https://uni-function.edgeone.app/ (Access with non-Chinese mainland network.)
- https://uni-function.netlify.app/
- https://uni-function.vercel.app/
- Fork the repository.
- Go to Cloudflare Dashboard -> Compute (Workers) -> Workers & Pages
- Click on "Create" and import a repository
- Select "GitHub" as the deployment source and select the forked repository.
- Configure the project:
- Build command:
npx deno task build:cloudflare
- Deploy command:
cd ./dist/cloudflare && npx wrangler deploy
- Build command:
- Click "Create and deploy" to deploy the project.
- Fork the repository.
- Go to Deno Deploy.
- Click on "New Project".
- Select "GitHub" as the deployment source and select the forked repository.
- Configure the project:
- Framework Preset:
none
- Entrypoint:
api/deno-deploy.ts
- Framework Preset:
- Click "Deploy Project" to deploy the project.
- Fork the repository.
- Go to Deno DeployEA.
- Click on "New app".
- Select "GitHub" as the deployment source and select the forked repository.
- Click Edit build config:
- Framework Preset:
No Preset
- Entrypoint:
api/deno-deploy.ts
- Framework Preset:
- Click "Create App" to deploy the project.
- Fork the repository.
- Go to EdgeOne Pages.
- Select "GitHub" as the deployment source and select the forked repository.
- Configure the project:
- Build output directory:
./edge-functions
- Install command:
npx deno task build:edgeone
- Build output directory:
- Click "Start deployment" to deploy the project.
- Fork the repository.
- Go to Netlify.
- Select "GitHub" as the deployment source and select the forked repository.
- Configure the project:
- Functions directory:
api
- Functions directory:
- Click "Deploy" to deploy the project.
- Fork the repository.
- Go to Vercel.
- Select "GitHub" as the deployment source and select the forked repository.
- Configure the project:
- Framework Preset:
Other
- Output Directory:
.
- Framework Preset:
- Click "Deploy" to deploy the project.
- Download the repository to your machine or VPS.
- Navigate to the project directory.
- Start the server:
npx deno task start
git clone https://github.com/mzl980425/uni-function.git
cd uni-function
deno task dev
# Or if you don't have the Deno environment, run:
npx deno task dev
# Then open in browser: http://localhost:8000/
uni-function uses a simple architecture:
- A central handler function (
src/handler.ts
) processes all incoming requests - Platform-specific adapters in the
api/
directory connect this handler to different cloud platforms - Each adapter imports the common handler and exposes it in the format required by its platform
- Build scripts in
deno.json
generate optimized deployments for each target platform
This approach allows you to write your function logic once in the handler, while the adapters take care of platform-specific requirements.
MIT License