Skip to content

Instantly share code, notes, and snippets.

@emeraldjava
Created May 1, 2021 14:57
Show Gist options
  • Save emeraldjava/0541eaa0341605fa276048ac9ce91ab2 to your computer and use it in GitHub Desktop.
Save emeraldjava/0541eaa0341605fa276048ac9ce91ab2 to your computer and use it in GitHub Desktop.
Running supabase js within a vanilla html page.
<html>
<header>
<title>Supabase</title>
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js"></script>
</header>
<body>
<h2>supabase</h2>
<script>
const { createClient } = supabase
supabase = createClient('https://dxxxxxz.supabase.co', 'api-key')
console.log('supabase'+supabase)
// use then()
supabase
.from('factor')
.select('*')
.limit(5)
.then(console.log)
.catch(console.error);
// use ananymous async/await functions
(async () => {
let { data, error } = await supabase
.from('event')
.select('*')
.limit(5)
if (error) {
console.log(error)
return
}
console.log(data)
})();
</script>
</body>
</html>
@fuzenco
Copy link

fuzenco commented Oct 27, 2021

Hi. I wanted to thank you for this code. I’m new to Supabase and JS in general. I was able to finally learn how to take a Supabase table and display it on my page thanks to you. So thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment