---
title: "Support for npm modules in Edge Functions"
description: "Netlify now allows you to use npm modules in your edge functions and leverage more than two million packages in the ecosystem to build your applications."
source: "https://www.netlify.com/blog/support-for-npm-modules-in-edge-functions/"
last_updated: "2026-07-14T17:08:17.000Z"
---
Two weeks ago, we [announced a reimagined experience for Netlify Functions](https://www.netlify.com/blog/introducing-netlify-functions-2-0/). It includes a brand new API based on standard `Request`/`Response` objects and the ability to configure routing within the function code.

If you’ve ever used Netlify Edge Functions, our other serverless compute product, you’re probably thinking that these features feel familiar. That’s because we took the things that developers love about Edge Functions and brought them to Functions, with the goal of creating a more unified experience across the two products.

We’re now approaching that goal from the other direction by taking one of the key features of the Functions offering and adding it to Edge Functions. Starting today, you can use npm modules in your edge functions and leverage more than two million packages in the ecosystem to build your applications.

## Getting started

Before using a module, start by adding it to your project. For instance, running the following command installs [lodash](https://www.npmjs.com/package/lodash).

```
npm install lodash
```

We’re using the npm client in this example, but you can replace that with your favorite package manager, like [Yarn](https://yarnpkg.com/), [pnpm](https://pnpm.io/) or [Bun](https://bun.sh/package-manager).

Just like with Functions, our build system will [automatically install your packages using the right package manager](https://docs.netlify.com/configure-builds/manage-dependencies/#javascript-dependencies) according to your project setup.

## Using modules

To use a module, load it into your edge function using [an `import` declaration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) and access it according to its documentation.

```
import type { Config, Context } from "@netlify/edge-functions"
import _ from "lodash"
const compiled = _.template("Hello, dear visitor from <%= country %>!")
export default async (req: Request, context: Context) => {  const text = compiled({ country: context.geo.country.name })
  return new Response(text)}
export const config: Config = {  path: "/hello",}
```

In this example, we’re rendering a message from a template using the geolocation data as input. If you deploy this edge function and access it, you should see a personalized message based on the country you’re accessing from.

Importing modules using full URLs is still possible and you can combine them with npm imports in the same file.

## We’d love to hear from you

We’re still hard at work to make this feature capable of handling all the different packages in the vast npm ecosystem with different module formats and characteristics. Still, we wanted to get this tool in the hands of our customers as early as possible, so we’re launching it as a beta feature that we’re hoping to improve in collaboration with you. If you use the [Netlify CLI](https://docs.netlify.com/cli/get-started/) to develop or deploy your functions, make sure you update to version 16.9.2 or above.

We invite you to try it and let us know about your experience through our [support portal](https://www.netlify.com/support) or our [community forum](https://community.netlify.com/).

### Share

-   [X (fka Twitter)](https://twitter.com/intent/tweet?text=Support for npm modules in Edge Functions&url=https://www.netlify.com/blog/support-for-npm-modules-in-edge-functions/)
-   [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.netlify.com%2Fblog%2Fsupport-for-npm-modules-in-edge-functions%2F)
-   [Facebook](https://www.facebook.com/sharer.php?u=https://www.netlify.com/blog/support-for-npm-modules-in-edge-functions/)
-   [Bluesky](https://bsky.app/intent/compose?text=Support for npm modules in Edge Functions+https://www.netlify.com/blog/support-for-npm-modules-in-edge-functions/)

* * *

### Tags

-   [changelog](/blog/tags/changelog/)
-   [Netlify Edge Functions](/blog/tags/netlify-edge-functions/)
-   [edge functions](/blog/tags/edge-functions/)
-   [npm](/blog/tags/npm/)

## Keep reading

![](/_astro/d0354fe52c160a3abdfdeff297a1baf090302a3d-1600x900_Z1eDdJG.webp)

News & Announcements July 14, 2026

[

### More headroom, a lower per-credit rate, and a bill you can predict: introducing new Pro plan tiers

](/blog/new-pro-plan-tiers)

-   ![Profile picture of Gehrig Kunz](/_astro/b4e9f58d914d1334ea70d53ea55a1f26b26f1445-512x512_17SwOI.webp)
    
    Gehrig Kunz
    

![](/_astro/8cc710924ebf8880283553465808eac2611fd379-1600x900_Z2eTTQe.webp)

News & Announcements July 13, 2026

[

### Netlify inside of Claude Design

](/blog/netlify-inside-of-claude-design)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

## Recent posts

News & Announcements July 14, 2026

[

### More headroom, a lower per-credit rate, and a bill you can predict: introducing new Pro plan tiers

](/blog/new-pro-plan-tiers)

-   ![Profile picture of Gehrig Kunz](/_astro/b4e9f58d914d1334ea70d53ea55a1f26b26f1445-512x512_17SwOI.webp)
    
    Gehrig Kunz
    

News & Announcements July 13, 2026

[

### Netlify inside of Claude Design

](/blog/netlify-inside-of-claude-design)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

News & Announcements June 25, 2026

[

### Netlify Functions, designed for Agent Experience

](/blog/netlify-functions-designed-for-agent-experience)

-   ![Profile picture of Eduardo Bouças](/_astro/52958f21e8450baf6d8e60302341a984e220c0cd-512x512_13VDlu.webp)
    
    Eduardo Bouças
    

![](/_astro/3f255b372fa958df35802666ee33b4609b2d71bd-1200x1586_1VtE2D.webp)

### How do the best dev and marketing teams work together?

[Access the report](https://www.netlify.com/reports/2024-leadership-trend-report/access/)