https://github.com/vercel/fun Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners + Executive Insights * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} vercel / fun Public * Notifications You must be signed in to change notification settings * Fork 28 * Star 526 fun - Local serverless function l development runtime License Apache-2.0 license 526 stars 28 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 12 * Pull requests 10 * Actions * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Security * Insights vercel/fun main BranchesTags [ ] Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 230 Commits .github/workflows .github/workflows example/dump example/dump src src test test util/python util/python .editorconfig .editorconfig .gitignore .gitignore .yarnrc .yarnrc README.md README.md license.md license.md package.json package.json pnpm-lock.yaml pnpm-lock.yaml release.config.js release.config.js tsconfig.json tsconfig.json View all files Repository files navigation * README * Apache-2.0 license * Security fun Build Status Local serverless function l development runtime. Example Given a Lambda function like this one: // example/index.js exports.handler = function(event, context, callback) { callback(null, { hello: 'world' }); }; You can invoke this function locally using the code below: import { createFunction } from '@vercel/fun'; async function main() { // Starts up the necessary server to be able to invoke the function const fn = await createFunction({ Code: { // `ZipFile` works, or an already unzipped directory may be specified Directory: __dirname + '/example' }, Handler: 'index.handler', Runtime: 'nodejs8.10', Environment: { Variables: { HELLO: 'world' } }, MemorySize: 512 }); // Invoke the function with a custom payload. A new instance of the function // will be initialized if there is not an available one ready to process. const res = await fn({ hello: 'world' }); console.log(res); // Prints: { hello: 'world' } // Once we are done with the function, destroy it so that the processes are // cleaned up, and the API server is shut down (useful for hot-reloading). await fn.destroy(); } main().catch(console.error); Caveats fun provides an execution environment that closely resembles the real Lambda environment, with some key differences that are documented here: * Lambdas processes are ran as your own user, not the sbx_user1051 user. * Processes are not sandboxed nor chrooted, so do not rely on hard-coded locations like /var/task, /var/runtime, /opt, etc. Instead, your function code should use the environment variables that represent these locations (namely LAMBDA_TASK_ROOT and LAMBDA_RUNTIME_DIR). * Processes are frozen by sending the SIGSTOP signal to the lambda process, and unfrozen by sending the SIGCONT signal, not using the cgroup freezer. * Lambdas that compile to native executables (i.e. Go) will need to be compiled for your operating system. So if you are on macOS, then the binary needs to be executable on macOS. Runtimes fun aims to support all runtimes that AWS Lambda provides. Currently implemented are: * nodejs for Node.js Lambda functions using the system node binary * nodejs6.10 for Node.js Lambda functions using a downloaded Node v6.10.0 binary * nodejs8.10 for Node.js Lambda functions using a downloaded Node v8.10.0 binary * nodejs10.x for Node.js Lambda functions using a downloaded Node v10.15.3 binary * nodejs12.x for Node.js Lambda functions using a downloaded Node v12.22.7 binary * nodejs14.x for Node.js Lambda functions using a downloaded Node v14.18.1 binary * python for Python Lambda functions using the system python binary * python2.7 for Python Lambda functions using a downloaded Python v2.7.12 binary * python3 for Python Lambda functions using the system python3 binary * python3.6 for Python Lambda functions using a downloaded Python v3.6.8 binary * python3.7 for Python Lambda functions using a downloaded Python v3.7.2 binary * go1.x for Lambda functions written in Go - binary must be compiled for your platform * provided for custom runtimes About fun - Local serverless function l development runtime Resources Readme License Apache-2.0 license Security policy Security policy Activity Custom properties Stars 526 stars Watchers 53 watching Forks 28 forks Report repository Releases 45 1.1.1 Latest Dec 13, 2023 + 44 releases Packages 0 No packages published Used by 27.9k * @linq * @Safaet-Rabbi * @IAmJera * @yousefraeis * @Syvia00 * @TheRodzz * @Boobalanfwd * @louisFortrie + 27,939 Contributors 15 * @TooTallNate * @styfle * @dependabot[bot] * @cb1kenobi * @amio * @thasophearak * @AndyBitz * @trek * @dpeek * @joecohens * @sionicion * @dfrankland * @stkevintan * @leo * @hamirmahal Languages * TypeScript 72.5% * Shell 11.9% * Go 8.7% * Python 4.2% * JavaScript 1.9% * Dockerfile 0.8% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.