Use Supabase with deno
Asked Answered
F

2

6

I'm trying to use Supabase with deno. I used import { createClient } from "https://esm.sh/@supabase/supabase-js" but it only gives me errors like Module '"deno:///missing_dependency.d.ts"' uses 'export =' and cannot be used with 'export *'

Francoisefrancolin answered 19/2, 2022 at 16:22 Comment(2)
try to import from this url for deno supabase: deno.land/x/supabase/mod.tsDarryl
Already saw that, but it throws an error too; I think it's outdatet not only because it's about 150 Commits behind supabase. Error: error: Uncaught TypeError: Cannot read properties of undefined (reading 'href') if (!url) url = window.location.hrefFrancoisefrancolin
F
3

Solved: Used import { createClient } from "https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm"

Francoisefrancolin answered 19/2, 2022 at 19:10 Comment(3)
It fixes the error, but in you lose the type definitions with this fileAvelin
It's worth noting that the official docs recommend to use esm.sh: import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'Headman
@Headman thanks I agree this worked for me use runtime in DenoCnemis
A
2

Using the Supabase Deno package works for me.

import { supabaseClient } from "https://deno.land/x/supabase_deno/mod.ts";
const sbclient = new supabaseClient("https://xyz.supabase.co","your-anon-key")
const sbTableItems = new supabaseTableItems(sbclient, "your-table");
const result = await sbTableItems.add(data);
Avelin answered 4/4, 2022 at 22:26 Comment(1)
Thanks, but that's literally my own code, I tried to do it on my own 👀Francoisefrancolin

© 2022 - 2024 — McMap. All rights reserved.