Skip to content

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

chore: document deno import.

thorwebdev0dc96aed6609
diff --git a/apps/docs/docs/reference/javascript/installing.mdx b/apps/docs/docs/reference/javascript/installing.mdx
index 8fdc1a90e8a..b5be32e09a4 100644
--- a/apps/docs/docs/reference/javascript/installing.mdx
+++ b/apps/docs/docs/reference/javascript/installing.mdx
@@ -8,30 +8,42 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
-All JavaScript libraries are built directly by the Supabase team. this is in reference/js/installing
-
-Other languages are built by the community and supported by Supabase.
-
## JavaScript
-Via NPM
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="npm"
+>
+<TabPanel id="npm" label="npm">
-```bash
+```sh
npm install @supabase/supabase-js
```
-Via Yarn
+</TabPanel>
+<TabPanel id="yarn" label="Yarn">
-```bash
+```sh
yarn add @supabase/supabase-js
```
-Find the source code on [GitHub](https://github.com/supabase/supabase-js).
+</TabPanel>
+</Tabs>
-Or via CDN
+### CDN
```js
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
//or
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
```
+
+## Deno
+
+You can use supabase-js in the Deno runtime via esm.sh:
+
+```ts
+import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
+```
diff --git a/examples/edge-functions/supabase/functions/get-tshirt-competition/index.ts b/examples/edge-functions/supabase/functions/get-tshirt-competition/index.ts
index 65ded062114..01e03605441 100644
--- a/examples/edge-functions/supabase/functions/get-tshirt-competition/index.ts
+++ b/examples/edge-functions/supabase/functions/get-tshirt-competition/index.ts
@@ -3,7 +3,7 @@
// This enables autocomplete, go to definition, etc.
import { serve } from 'https://deno.land/[email protected]/http/server.ts'
-import { createClient } from 'https://esm.sh/@supabase/[email protected]'
+import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
import { corsHeaders } from '../_shared/cors.ts'
console.log(`Function "get-tshirt-competition" up and running!`)
diff --git a/examples/edge-functions/supabase/functions/read-storage/index.ts b/examples/edge-functions/supabase/functions/read-storage/index.ts
index b1fbbf96ba3..d7247b800dc 100644
--- a/examples/edge-functions/supabase/functions/read-storage/index.ts
+++ b/examples/edge-functions/supabase/functions/read-storage/index.ts
@@ -2,8 +2,8 @@
// https://deno.land/manual/getting_started/setup_your_environment
// This enables autocomplete, go to definition, etc.
-import { serve } from "https://deno.land/[email protected]/http/server.ts"
-import { createClient } from 'https://esm.sh/@supabase/[email protected]'
+import { serve } from 'https://deno.land/[email protected]/http/server.ts'
+import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
@@ -29,14 +29,11 @@ serve(async (req) => {
{ global: { headers: { Authorization: req.headers.get('Authorization')! } } }
)
- const { data, error } = await supabaseClient
- .storage
- .from('my-bucket')
- .download('sample.txt')
+ const { data, error } = await supabaseClient.storage.from('my-bucket').download('sample.txt')
if (error) throw error
// file contents are returned as a blob, we can convert it to utf-8 text by calling text() method.
- const contents = await data.text();
+ const contents = await data.text()
// prints out the contents of the file
console.log(contents)
@@ -45,14 +42,12 @@ serve(async (req) => {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
})
-
} catch (error) {
- console.error(error);
+ console.error(error)
return new Response(JSON.stringify({ error: error.message }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 400,
})
}
-
})
diff --git a/examples/edge-functions/supabase/functions/restful-tasks/index.ts b/examples/edge-functions/supabase/functions/restful-tasks/index.ts
index 7451c623890..67c36ed0a98 100644
--- a/examples/edge-functions/supabase/functions/restful-tasks/index.ts
+++ b/examples/edge-functions/supabase/functions/restful-tasks/index.ts
@@ -2,8 +2,8 @@
// https://deno.land/manual/getting_started/setup_your_environment
// This enables autocomplete, go to definition, etc.
-import { serve } from "https://deno.land/[email protected]/http/server.ts"
-import { createClient } from 'https://esm.sh/@supabase/[email protected]'
+import { serve } from 'https://deno.land/[email protected]/http/server.ts'
+import { createClient, SupabaseClient } from 'https://esm.sh/@supabase/supabase-js@2'
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
@@ -11,58 +11,58 @@ const corsHeaders = {
}
interface Task {
- name: string;
- status: number;
+ name: string
+ status: number
}
-async function getTask(supabaseClient: any, id: string) {
- const { data: task, error } = await supabaseClient.from('tasks').select('*').eq('id', id);
+async function getTask(supabaseClient: SupabaseClient, id: string) {
+ const { data: task, error } = await supabaseClient.from('tasks').select('*').eq('id', id)
if (error) throw error
return new Response(JSON.stringify({ task }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
- });
+ })
}
-async function getAllTasks(supabaseClient: any) {
+async function getAllTasks(supabaseClient: SupabaseClient) {
const { data: tasks, error } = await supabaseClient.from('tasks').select('*')
if (error) throw error
return new Response(JSON.stringify({ tasks }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
- });
+ })
}
-async function deleteTask(supabaseClient: any, id: string) {
- const { error } = await supabaseClient.from('tasks').delete().eq('id', id);
+async function deleteTask(supabaseClient: SupabaseClient, id: string) {
+ const { error } = await supabaseClient.from('tasks').delete().eq('id', id)
if (error) throw error
return new Response(JSON.stringify({}), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
- });
+ })
}
-async function updateTask(supabaseClient: any, id: string, task: Task) {
- const { error } = await supabaseClient.from('tasks').update(task).eq('id', id);
+async function updateTask(supabaseClient: SupabaseClient, id: string, task: Task) {
+ const { error } = await supabaseClient.from('tasks').update(task).eq('id', id)
if (error) throw error
return new Response(JSON.stringify({ task }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
- });
+ })
}
-async function createTask(supabaseClient: any, task: Task) {
- const { error } = await supabaseClient.from('tasks').insert(task);
+async function createTask(supabaseClient: SupabaseClient, task: Task) {
+ const { error } = await supabaseClient.from('tasks').insert(task)
if (error) throw error
return new Response(JSON.stringify({ task }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
- });
+ })
}
serve(async (req) => {
@@ -90,10 +90,10 @@ serve(async (req) => {
const matchingPath = taskPattern.exec(url)
const id = matchingPath ? matchingPath.pathname.groups.id : null
- let task = null;
- if (method === "POST" || method === "PUT") {
- const body = await req.json();
- task = body.task;
+ let task = null
+ if (method === 'POST' || method === 'PUT') {
+ const body = await req.json()
+ task = body.task
}
// call relevant method based on method and id
@@ -112,7 +112,7 @@ serve(async (req) => {
return getAllTasks(supabaseClient)
}
} catch (error) {
- console.error(error);
+ console.error(error)
return new Response(JSON.stringify({ error: error.message }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
diff --git a/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts b/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts
index eb74cca8c38..f9dedb16a7d 100644
--- a/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts
+++ b/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts
@@ -3,7 +3,7 @@
// This enables autocomplete, go to definition, etc.
import { serve } from 'https://deno.land/[email protected]/http/server.ts'
-import { createClient } from 'https://esm.sh/@supabase/[email protected]'
+import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
import { corsHeaders } from '../_shared/cors.ts'
console.log(`Function "select-from-table-with-auth-rls" up and running!`)