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.
Usage example
Section titled “Usage example”import { NetlifyExtension } from "@netlify/sdk";
const extension = new NetlifyExtension();
// Adding a build event handlerextension.addBuildEventHandler("onPreBuild", () => { console.log("This is my first build event handler!");});
Type parameters
Section titled “Type parameters”Name | Type |
---|---|
SiteConfigSchema | ZodSchema , undefined |
TeamConfigSchema | ZodSchema , undefined |
BuildContext | ZodSchema , undefined |
BuildConfigSchema | ZodSchema , undefined |
Methods
Section titled “Methods”addBuildEventContext
Section titled “addBuildEventContext”addBuildEventContext(func)
Used to add a build context to the extension that can be used in a build event handler.
Parameters
Section titled “Parameters”Name | Type |
---|---|
handler | func |
Returns
Section titled “Returns”Returns a promise with an object
.
addBuildEventHandler
Section titled “addBuildEventHandler”addBuildEventHandler(type, func)
Used to add a build event handler to the extension.
Parameters
Section titled “Parameters”Name | Type |
---|---|
type | BuildHookType , one of the build events |
func | func |
Returns
Section titled “Returns”void
addEdgeFunctions
Section titled “addEdgeFunctions”addEdgeFunctions(path, options)
Used to inform the extension that you want to inject edge functions into the user’s project.
Parameters
Section titled “Parameters”Name | Type |
---|---|
path | string |
options | EdgeFunctionsOptions |
Returns
Section titled “Returns”void
addFunctions
Section titled “addFunctions”addFunctions(path, options)
Used to inform the extension that you want to inject functions into the user’s project.
Parameters
Section titled “Parameters”Name | Type |
---|---|
path | string |
options | FunctionsOptions |
Returns
Section titled “Returns”void