Skip to content

NetlifyIntegration

The NetlifyIntegration provides different methods to help create your integration.

Usage example

src/index.ts
import { NetlifyIntegration } from "@netlify/sdk";
const integration = new NetlifyIntegration();
// Adding a build event handler
integration.addBuildEventHandler("onPreBuild", () => {
console.log("This is my first build event handler!");
});

Type parameters

NameType
SiteConfigSchemaZodSchema, undefined
TeamConfigSchemaZodSchema, undefined
BuildContextZodSchema, undefined
BuildConfigSchemaZodSchema, undefined

Methods

addApiHandler

addApiHandler(name, func)

Used to add an API handler to the integration.

Parameters

NameType
namestring
funcfunc

Returns

void


addBuildEventContext

addBuildEventContext(func)

Used to add a build context to the integration that can be used in a build event handler.

Parameters

NameType
handlerfunc

Returns

Returns a promise with an object.


addBuildEventHandler

addBuildEventHandler(type, func)

Used to add a build event handler to the integration.

Parameters

NameType
typeBuildHookType, one of the build events
funcfunc

Returns

void


addConnector

addConnector(config)

Used to create a connector for the integration.

Parameters

NameType
configConnectorConfig

Returns

A NetlifyConnector.


addEdgeFunctions (beta)

addEdgeFunctions(path, options)

Used to inform the integration that you want to inject edge functions into the user’s site.

This SDK functionality is currently in beta. The API may change in future releases.

Parameters

NameType
pathstring
optionsEdgeFunctionsOptions

Returns

void


addFunctions (beta)

addFunctions(path, options)

Used to inform the integration that you want to inject functions into the user’s site.

This SDK functionality is currently in beta. The API may change in future releases.

Parameters

NameType
pathstring
optionsFunctionsOptions

Returns

void


onDisable

onDisable(func)

Used to customize the disablement flow. If your custom handler returns a 200 or 204 status code, the integration will be disabled; otherwise, the integration will be enabled.

Warning: The code defined in the onDisable method will still complete even if the integration is not disabled. Be sure the actions you take here are idempotent.

Parameters

NameType
funcfunc

Returns

void


onEnable

onEnable(func)

Used to customize the enablement flow. The code defined in an onEnable handler will run after the integration is enabled.

Parameters

NameType
funcfunc

Returns

void