Autoscaling Report: Production databases on Neon use 2.4x less compute and 50% less cost than if they were running on a provisioned platform.
/Neon Functions/Deploy and manage

Deploy and manage Neon Functions

CLI and API reference for deploying and managing Neon Functions.

Private Preview

This feature is in private preview: it's not ready for production use, and it may be briefly unavailable as we deploy updates. To get access, sign up here.

Deploy withneon.ts

If your project has a neon.ts config, this is the recommended way to deploy. neon deploy reads the config and applies the entire branch policy in one step: services, per-branch tuning, and every function it declares:

neon deploy
FlagDefaultDescription
--configwalks up from cwdPath to the neon.ts policy
--env(none)Path to a .env file loaded before neon.ts is evaluated, so function env values resolve from it
--branchlinked branchTarget branch ID or name
--project-idlinked projectProject ID
--update-existingfalseAuto-confirm overriding existing remote settings on the branch
--allow-protectedfalseAuto-confirm applying to a branch marked protected on Neon

neon deploy is an alias for neon config apply. To preview what a deploy would change without applying it, run neon config plan.

Note that --env here takes a path to a .env file. The --env flag on neon functions deploy below takes KEY=VALUE pairs instead.

Deploy withneon functions deploy

To deploy one function directly, without a neon.ts config:

neon functions deploy <slug> [--src <dir-or-entry-file>] [--env KEY=VALUE] [--wait]

The CLI bundles with esbuild, zips the output, and uploads it. The first deploy creates the function; subsequent deploys update it. See the neon functions reference for the full command surface.

FlagDefaultDescription
--src(none)Function source: a directory containing index.ts, index.mjs, or index.js, or a path to the entry file
--env KEY=VALUE(none)Set an environment variable. Repeatable. Stored with the deployment. Takes KEY=VALUE pairs, not a .env file path like neon deploy --env
--runtimenodejs24Function runtime. nodejs24 is the only valid value
--branchlinked branchTarget branch. Defaults to the branch in .neon
--waittruePoll until completed or failed, up to 10 minutes

Examples:

neon functions deploy hello --src functions/hello.ts
neon functions deploy hello --src . --env RESEND_API_KEY=re_...
neon functions deploy hello --src functions/hello.ts --branch feat/my-feature

Deploy with the API

Bundle with esbuild, zip the output, then POST to the deploy endpoint.

1. Bundle:

esbuild functions/hello.ts --bundle --platform=node --target=node24 --outfile=dist/index.mjs

2. Zip:

zip -j function.zip dist/index.mjs

The archive's entry file must be named index.mjs or index.js; the runtime looks for those names.

From Node.js, buildFunctionBundle from @neon/config-runtime does both steps in one call and produces exactly the archive the deploy endpoint expects:

import { buildFunctionBundle } from "@neon/config-runtime/v1";

const zip = await buildFunctionBundle({
  slug: "hello",
  name: "My first function",
  source: "./functions/hello.ts",
  env: {},
  runtime: "nodejs24",
});

3. Deploy:

curl -X POST \
  "https://console.neon.tech/api/v2/projects/{project_id}/branches/{branch_id}/functions/{slug}/deployments" \
  -H "Authorization: Bearer $NEON_API_KEY" \
  -F "zip=@function.zip" \
  -F 'environment={"MY_SECRET":"value"}'
FieldTypeRequiredDescription
zipbinaryWhen code changesZIP of the bundled function. Omit only to update environment or runtime on an existing deployment
runtimestringNonodejs24 is the only valid value
environmentstringNoJSON-encoded string-to-string map

The API returns immediately. Poll the get endpoint (see Check status) until the deployment completes.

Slugs

The slug is assigned at first deploy: either the key in neon.ts or the positional argument to neon functions deploy. It becomes part of the invocation URL and can't be changed afterward. Slugs must match ^[a-z0-9]{1,20}$: lowercase letters and digits only, 1 to 20 characters, no hyphens.

Deployment states

StateMeaning
pendingQueued, not yet building
buildingSource is being compiled and bundled
completedFunction is live and accepting requests
failedBuild or deployment error

Manage functions

Check status

neon functions get hello

The response includes invocation_url, the public URL for your function:

https://<branch_id>-<slug>.compute.<cell>.us-east-2.aws.neon.tech

List functions

neon functions list

Delete a function

neon functions delete hello

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Was this page helpful?
Edit on GitHub