Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: updated docs on using npm modules (#19618)

Lakshan Perera4bade5a1552b
diff --git a/apps/docs/pages/guides/functions/import-maps.mdx b/apps/docs/pages/guides/functions/import-maps.mdx
index d0916c076ca..df35809a30c 100644
--- a/apps/docs/pages/guides/functions/import-maps.mdx
+++ b/apps/docs/pages/guides/functions/import-maps.mdx
@@ -16,24 +16,40 @@ Supabase Edge Functions support:
- The Deno [standard library](https://deno.land/std)
- Third party [modules](https://deno.land/x)
+- Built-in [Node APIs](https://docs.deno.com/runtime/manual/node/compatibility)
- Node.js modules published to npm
-We recommend using [esm.sh](https://esm.sh/) for importing modules that are published to npm. To do so, put `https://esm.sh/` in front of the package name. For example, import the `supabase-js` package like this:
+You can import npm modules using the `npm:` specifier or via CDNs like [esm.sh](https://esm.sh). For example, to import the `supabase-js` package:
```ts
-import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
+import { createClient } from 'npm:@supabase/supabase-js@2'
```
-<Admonition label="npm support">
+If you are migrating an existing Node app and if it uses a built-in Node APIs, you can import them to Deno using `node:` specifiers. For example, if your code uses `process.env`, you can import it as follows:
-Full support for NPM is under development and coming soon.
+```ts
+import process from 'node:process'
+```
-</Admonition>
+You can learn more about `npm:` specifiers and Node built-in APIs, in [Deno's documentation](https://docs.deno.com/runtime/manual/node/npm_specifiers).
## Importing Types
If your [environment is set up properly](/docs/guides/functions/local-development) and the module you're importing is exporting types, the import will have types and autocompletion support.
+Some npm packages may not ship out of the box types and you may need to import them from a separate package. You can specify their types with a `@deno-types` directive:
+
+```ts
+// @deno-types="npm:@types/express@^4.17"
+import express from 'npm:express@^4.17'
+```
+
+To include types for built-in Node APIs, add the following line to the top of your imports:
+
+```ts
+/// <reference types="npm:@types/node" />
+```
+
## Using Import Maps
An [Import Map](https://github.com/WICG/import-maps#the-import-map) is similar to a `package.json` file. They are a way to manage your dependencies. Consider this code: