Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 5 min read Announcement mediumAdept

Your Neon Functions can now run on a schedule

Neon Function Triggers let Neon invoke a deployed Node.js function on a cron schedule. Because the timer lives outside the Postgres compute, scheduled jobs keep working with scale to zero, unlike pg_cron, which only runs while the compute is up and can only execute SQL. Triggers are branch-scoped, and child branches inherit their parent's triggers in a disabled state, so branching production doesn't double-fire jobs. A worked example uses a Hono handler that verifies the X-Neon-Trigger-Invocation-Id header, reads scheduled_at from the request body, and uses ON CONFLICT DO NOTHING to stay idempotent, plus the API call that creates a 15-minute schedule.

Assumes: Postgres basicscron expressionsserverless functions

Related posts

  • Neon Functions: backend logic next to your data

    Neon mediumAdept

    Neon Functions are long-running Node.js 24 compute deployed onto a Neon branch, in the same region and on the same infrastructure as its Lakebase Postgres database, with DATABASE_URL and other Neon backend credentials injected automatically. Running next to the data removes the cross-network hop per query and lets a function keep a pg Pool open across requests, so agents can stream for minutes and WebSockets or SSE can fan out via Postgres LISTEN/NOTIFY. Functions branch with the database: each child branch gets its own function copy and URL, and deleting the branch deletes it. They are declared in neon.ts, Hono is the recommended framework, and the pg Pool is recommended over the serverless driver; functions are not for frontend hosting or background jobs, and cron and event triggers are planned.

  • Postgres as a CRON Server

    Supabase mediumAdept

    Postgres can act as a cron server by combining the pg_cron extension for scheduling with the pgsql-http extension for outbound HTTP calls, letting a scheduled SQL statement POST to a webhook every minute. The walkthrough covers enabling both extensions, granting cron schema access to non-superuser roles, cron syntax, and inspecting or unscheduling jobs via cron.job and cron.job_run_details. pg_cron runs jobs in background workers so slow endpoints don't block core Postgres, but setting http.timeout_msec to fail fast is still recommended. Suggested uses include batching welcome emails, aggregating data and deleting old rows.

  • Postgres Event Triggers Are Now Supported in Neon

    Neon mediumAdept

    Neon now supports Postgres event triggers through the neon_superuser role, and they behave exactly as in vanilla Postgres. Unlike row-level triggers, event triggers fire on DDL commands such as CREATE, ALTER and DROP. They can audit schema changes on ddl_command_end, automate metadata updates or alerts, and feed schema changes to sync engines like Zero via pg_event_trigger_ddl_commands(). Short examples show blocking DROP TABLE for non-admin roles and cleaning up orphaned pg_cron jobs on sql_drop using pg_event_trigger_dropped_objects().

  • When a file is uploaded, run the job on Neon

    Neon mediumAdept

    Neon added a storage_object_created function trigger that invokes a Neon Function via HTTP POST when an object is created in a Neon Object Storage bucket, optionally filtered by key prefix. The payload carries the bucket name and object key. Functions are long-running and scale to zero, and they wake Postgres compute on demand. Example pipelines include cataloging uploads in Postgres, generating image variants under a separate prefix to avoid self-triggering, AI tagging, PDF chunking and embedding for search, and moderation, which runs after the upload lands and so cannot block it. Triggers branch with the data but are disabled by default on child branches, and they can be declared in a neon.ts config file alongside buckets and functions.

  • Run Scheduled and Recurring Tasks with Cron

    Railway mediumAdept

    Cron runs commands on time-based schedules but keeps no job history, has no retries and does no concurrency control, so reliability depends on the job itself. The guide covers the five-field schedule syntax, including the day-of-month/weekday OR pitfall and timezone/DST issues, and recommends idempotent upserts, structured start/success/error logs, explicit connection cleanup, and Postgres advisory locks to prevent overlapping runs. On Railway, cron triggers a service's start command in UTC with a 5-minute minimum interval and a single active execution. A process left alive by open handles or pending promises causes later runs to be skipped.

The quest for software engineering knowledge.

Look:
Layout: