Skip to content

NetlifyExtension

The NetlifyExtension provides different methods to help create your extension.

Review TypeScript definitions in the SDK

When you install the Netlify SDK, you have access to the TypeScript definitions directly in the @netlify/sdk package. You can browse through the definition files individually or review the type definition inline depending on your code editor.

src/index.ts
import { NetlifyExtension } from "@netlify/sdk";
const extension = new NetlifyExtension();
// Adding a build event handler
extension.addBuildEventHandler("onPreBuild", () => {
console.log("This is my first build event handler!");
});
NameType
SiteConfigSchemaZodSchema, undefined
TeamConfigSchemaZodSchema, undefined
BuildContextZodSchema, undefined
BuildConfigSchemaZodSchema, undefined

addBuildEventContext(func)

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

NameType
handlerfunc

Returns a promise with an object.


addBuildEventHandler(type, func)

Used to add a build event handler to the extension.

NameType
typeBuildHookType, one of the build events
funcfunc

void


addEdgeFunctions(path, options)

Used to inform the extension that you want to inject edge functions into the user’s project.

NameType
pathstring
optionsEdgeFunctionsOptions

void


addFunctions(path, options)

Used to inform the extension that you want to inject functions into the user’s project.

NameType
pathstring
optionsFunctionsOptions

void

Got it!

Your feedback helps us improve our docs.