Get started with endpoints
This page will help you get started with creating an extension that uses endpoints. It describes how to generate the boilerplate code for an extension with an endpoint, what the required files and basic scaffolding are, and how to build your code.
Prerequisites
Windows users should run the Netlify SDK through WSL 2
Support for using the Netlify SDK on Windows is currently only available through WSL 2.
- Node.js 18.19.0 or later
- Netlify CLI
- TypeScript
Create your endpoint
-
To get started, run the following command to create a new extension:
-
Then, follow the prompts to add the
Build Event Handler
orExtension UI
boilerplate.The Netlify SDK will scaffold the basic structure needed for your extension. Learn about the required files in the anatomy of an extension doc.
-
Create a file at
src/endpoints/my-function.ts
and create your first endpoint:
Develop your endpoint
Now that you’ve added an endpoint to your extension, you can tailor it to fit your needs.
- Use values and methods to develop the logic for your endpoint.
- Add code to call your endpoint from extension UI.
- Debug and test your endpoint to make sure it works as expected.
If your endpoint makes calls to a third-party API that requires authentication, you can configure your extension to allow users to authenticate through an OAuth identity provider. Once a user authenticates, you can access the OAuth token and use it to make requests on the user’s behalf.
Synchronous serverless functions only
Endpoints do not support Scheduled Functions or Background Functions.
Build your endpoint
Once you’re done developing your endpoint, you can compile your code by using the following Netlify SDK command:
The code is compiled to the .netlify
directory. These functions are deployed and hosted by Netlify when you publish your extension, you don’t need to deploy these functions separately once they’re built.
Next steps
- Configure your extension to allow users to authenticate with an OAuth identity provider.
- Learn how to publish your extension when you’re ready to share it with users.