# How to Use the Netlify Plugin for Serverless Deployments: Complete Setup Guide

> Master serverless deployments with the Netlify plugin. Discover automatic function discovery, CLI tooling, and SDK support for seamless builds and testing.

- Repository: [OpenAI/plugins](https://github.com/openai/plugins)
- Tags: how-to-guide
- Published: 2026-07-04

---

**The Netlify plugin provides a complete stack for building, testing, and deploying serverless applications on Netlify through automatic function discovery, CLI tooling, and integrated SDK support.**

The `openai/plugins` repository includes a dedicated Netlify plugin that streamlines the creation and deployment of serverless functions. This plugin implements the same architecture that Netlify uses internally, offering a structured approach to building serverless applications with TypeScript and JavaScript. By following the patterns defined in [`plugins/netlify/skills/netlify-functions/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-functions/SKILL.md), you can deploy production-ready endpoints without managing infrastructure.

## Understanding the Netlify Plugin Architecture

The plugin organizes serverless deployments into three core components: **Netlify Functions**, **configuration files**, and **CLI tooling**. According to the source code in [`plugins/netlify/skills/netlify-functions/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-functions/SKILL.md), functions are automatically discovered when placed in the `netlify/functions/` directory and exposed at the `/.netlify/functions/<function-name>` endpoint.

### Function Structure and Discovery

Each TypeScript or JavaScript file placed under `netlify/functions/` becomes a standalone serverless endpoint. The plugin expects functions to follow the standard Netlify signature using types from `@netlify/functions`.

### Configuration Management

The [`netlify.toml`](https://github.com/openai/plugins/blob/main/netlify.toml) file, documented in [`plugins/netlify/skills/netlify-deploy/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-deploy/SKILL.md), controls build settings, redirect rules, and edge-function routing. Netlify reads this configuration during the build process to generate final deployment assets.

## Setting Up Your First Serverless Function

To create a serverless function, add a TypeScript file to the `netlify/functions/` directory. As specified in [`plugins/netlify/skills/netlify-functions/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-functions/SKILL.md), each function receives a `Context` and optional `Config` type from the `@netlify/functions` package.

```typescript
// netlify/functions/hello.ts
import type { Handler, Context } from "@netlify/functions";

export const handler: Handler = async (event, context: Context) => {
  return {
    statusCode: 200,
    body: JSON.stringify({ message: "👋 Hello from Netlify Functions!" }),
  };
};

```

This code automatically becomes available at `/.netlify/functions/hello` once deployed.

## Configuring Routing with netlify.toml

The [`netlify.toml`](https://github.com/openai/plugins/blob/main/netlify.toml) file defines how requests route to your functions and static assets. Based on the documentation in [`plugins/netlify/skills/netlify-deploy/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-deploy/SKILL.md), you can configure redirects to map custom paths to function endpoints.

```toml

# netlify.toml (project root)

[build]
  functions = "netlify/functions"
  publish = "dist"

[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/:splat"
  status = 200

```

This configuration redirects all `/api/*` requests to the corresponding function, hiding the internal `/.netlify/functions/` path from end users.

## Deploying with the Netlify CLI

The deployment process uses the Netlify CLI to package your site, upload functions, and generate preview URLs. According to [`plugins/netlify/skills/netlify-cli-and-deploy/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-cli-and-deploy/SKILL.md), the plugin supports both preview and production deployments.

First, install the CLI globally:

```bash
npm install -g netlify-cli

```

Then deploy a preview build:

```bash
netlify deploy --build

```

This command runs the build process, uploads your functions, and returns a unique preview URL. Once verified, deploy to production:

```bash
netlify deploy --prod

```

## Accessing Runtime Primitives and Storage

The plugin bundles official Netlify SDKs including `@netlify/functions`, `@netlify/blobs`, and `@netlify/identity`, enabling direct access to platform primitives from within your code.

### Environment Variables

Environment variables are automatically injected at build time and accessible via `process.env` without additional tooling. This works out of the box for both local development and deployed functions.

### Blob Storage for Binary Data

For large binary payloads such as image uploads, the plugin includes blob storage support documented in [`plugins/netlify/skills/netlify-blobs/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-blobs/SKILL.md). Use the `@netlify/blobs` package to read and write persistent data.

```typescript
import { getStore } from "@netlify/blobs";

export const handler = async () => {
  const store = getStore("my-store");
  await store.set("image.png", "binary-data-here");
  
  return {
    statusCode: 200,
    body: "Blob stored successfully"
  };
};

```

## Summary

- Place serverless functions in `netlify/functions/` to automatically expose them at `/.netlify/functions/<name>`
- Configure routing, builds, and redirects in [`netlify.toml`](https://github.com/openai/plugins/blob/main/netlify.toml) as documented in [`plugins/netlify/skills/netlify-deploy/SKILL.md`](https://github.com/openai/plugins/blob/main/plugins/netlify/skills/netlify-deploy/SKILL.md)
- Use the Netlify CLI (`netlify deploy --build`) to create preview deployments before pushing to production
- Access environment variables through `process.env` and binary storage through `@netlify/blobs` without additional configuration
- Reference the skill files in `plugins/netlify/skills/` for detailed implementation patterns and best practices

## Frequently Asked Questions

### How do I install the Netlify plugin from the openai/plugins repository?

The Netlify plugin is included in the `openai/plugins` repository under [`plugins/netlify/.codex-plugin/plugin.json`](https://github.com/openai/plugins/blob/main/plugins/netlify/.codex-plugin/plugin.json). You do not need to install the plugin itself separately; instead, install the Netlify CLI and the required SDKs (`npm i @netlify/functions`) in your project to begin using the patterns documented in the skill files.

### What is the correct file structure for Netlify Functions?

Place all serverless function files in the `netlify/functions/` directory at your project root. Each file (such as [`hello.ts`](https://github.com/openai/plugins/blob/main/hello.ts)) automatically becomes an endpoint at `/.netlify/functions/<filename>`. The build configuration in [`netlify.toml`](https://github.com/openai/plugins/blob/main/netlify.toml) can customize this directory, but `netlify/functions/` is the default convention used by the plugin.

### How do I access environment variables in Netlify Functions?

Environment variables are automatically injected at build time and runtime. Access them directly through `process.env.VARIABLE_NAME` within your function code. The plugin handles the injection automatically, so no additional import or configuration is required beyond setting the variables in your Netlify dashboard or local `.env` file.

### Can I test Netlify Functions locally before deploying?

Yes. Use the `netlify dev` command to run a local development server that emulates the Netlify Functions environment. This allows you to test endpoints at `http://localhost:8888/.netlify/functions/<function-name>` before running `netlify deploy --build` to create a preview deployment.