> ## Documentation Index
> Fetch the complete documentation index at: https://nango.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# React to connection lifecycle events

> Run integration logic when a connection is validated, created, or deleted.

Some integration work should happen around the connection lifecycle rather than from a user action or schedule. For example, you may need to verify credentials before accepting a connection, register provider webhooks after authorization, or clean up subscriptions before a customer disconnects.

Nango supports this with event functions. They run automatically for a specific integration and connection event.

## When this fits

Use event functions when you need to:

* Validate credentials or provider permissions during connection creation.
* Register external webhook subscriptions after a connection is created.
* Fetch account context and store it as connection metadata.
* Clean up provider resources before a connection is deleted.

These functions are not called by your app directly. Nango runs them when the configured lifecycle event occurs.

## How Nango fits in

1. Your user creates or deletes a connection.
2. Nango detects the lifecycle event.
3. Nango runs the event function with that connection's credentials.
4. The function validates, initializes, registers, or cleans up provider-side resources.
5. The execution appears in Nango logs.

## What to read next

* [Event functions](/guides/functions/event-functions) - supported events, function syntax, testing, and deployment.
* [Webhook functions](/guides/functions/webhook-functions) - register and process external webhooks.
* [Storage](/guides/functions/storage) - store account context on the connection.
* [Functions SDK reference](/reference/functions/functions-sdk#createonevent) - `createOnEvent()` reference.
