Skip to content

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

chore: adds replit blog post

awalias50c24731cffe
diff --git a/web/blog/2021-03-11-using-supabase-replit.md b/web/blog/2021-03-11-using-supabase-replit.md
new file mode 100644
index 00000000000..725e34510a5
--- /dev/null
+++ b/web/blog/2021-03-11-using-supabase-replit.md
@@ -0,0 +1,136 @@
+---
+title: Using Supabase in Replit
+description: Free hosted relational database from within your node.js repl
+author: Ant Wilson
+author_title: Supabase
+author_url: https://github.com/awalias
+author_image_url: https://github.com/awalias.png
+authorURL: https://github.com/awalias
+image: /img/blog/replit-og.jpg
+tags:
+ - Replit
+ - node-js
+ - Postgres
+---
+
+[Replit.com](http://replit.com) is an awesome new browser based IDE where you can code alone or collaboratively with friends using their awesome multiplayer features! It's particularly useful for education, and sharing code examples with others.
+
+They support a ton of different languages and execution environments and even recently introduced a simple key value store you can use to persist data.
+
+As a Replit user, if you want to access larger amounts of data direct from your repl, or if you fancy accessing some super-powerful query tools, at some point you may want to start interacting with a relational database. Supabase is a good fit here; just like Replit, you don't need to worry about servers, and hosting, you can just click a few buttons and get a fully featured relational database which you can start communicating with directly from javacript, using supabase-js.
+
+<iframe className="w-full video-with-border" width="640" height="385" src="https://www.youtube-nocookie.com/embed/lQ5iIxaYduI" frameBorder="1" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>
+
+Here's how to start a Supabase + Node.js repl:
+
+Sign up for [replit.com](http://replit.com) and hit new repl in the top left
+
+
+![Untitled-2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u3dljulzsyqu58i75epn.png)
+
+
+Select node.js, give it a name, and click Create repl
+
+
+![Untitled-1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rcfbb12sfabevto571j.png)
+
+
+Import supabase's createClient method and hit run to install the required libs:
+
+```jsx
+const { createClient } = require('@supabase/supabase-js')
+```
+
+Setup a new Supabase project and grab the URL and anon key from Settings > API. Create the client in javascript using:
+
+```jsx
+const supabase = createClient(
+ 'https://ajsstlnzcmdmzbtcgbbd.supabase.co',
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
+)
+```
+
+
+![Untitled-3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5j5aqyjdh74qm83slmli.png)
+
+
+Now that supabase is connected you'll want to add some data to your db, you can grab any SQL dataset on the web, or make your own, but the fasted way to test is to open the SQL tab in the Supabase dashboard and click the Countries sample database and click Run.
+
+
+![Untitled-4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54yykm6h9hqpric87zad.png)
+
+
+From within your repl you can now query your countries table like:
+
+```jsx
+// .then() syntax
+supabase.
+ .from('countries')
+ .select('*')
+ .limit(5)
+ .then(console.log)
+ .catch(console.error)
+
+// or...
+// async/await syntax
+const main = async() => {
+ let { data, error } = supabase
+ .from('countries')
+ .select('*')
+ .limit(5)
+
+ if (error) {
+ console.log(error)
+ return
+ }
+
+ console.log(data)
+}
+main()
+```
+
+Once this is working, if you want to learn more about the [query interface](https://supabase.io/docs/client/filter) you might want to try some of these challenges:
+
+```jsx
+// 1. List all the countries in Antarctica
+// 2. Fetch the iso3 code of the country with ID 3
+// 3. List the countries with 'Island' in the name
+// 4. Count the number of countries that start with 'Z' or 'Q'
+// 5. Fetch all the Countries where continents is null
+```
+
+There are full solutions provided in the video version of this blog, but some examples you may find useful are:
+
+```jsx
+// or
+const { data, error } = await supabase
+ .from('cities')
+ .select('name, country_id')
+ .or('id.eq.20,id.eq.30')
+
+// is
+const { data, error } = await supabase
+ .from('cities')
+ .select('name, country_id')
+ .is('name', null)
+
+// in
+const { data, error } = await supabase
+ .from('cities')
+ .select('name, country_id')
+ .in('name', ['Rio de Janeiro', 'San Francisco'])
+
+// neq (not equal to)
+const { data, error } = await supabase
+ .from('cities')
+ .select('name, country_id')
+ .neq('name', 'The shire')
+
+// full docs here: https://supabase.io/docs/client/filter
+```
+
+We look forward to showing off some more Supabase + Replit examples.
+
+You can find my example repl here: [https://repl.it/@awalias/supabase-test#index.js](https://repl.it/@awalias/supabase-test#index.js)
+
+Supabase has a free tier, head over to [https://app.supabase.io](https://app.supabase.io) to get started.
diff --git a/web/static/img/blog/replit-og.jpg b/web/static/img/blog/replit-og.jpg
new file mode 100644
index 00000000000..75db5880ee1
Binary files /dev/null and b/web/static/img/blog/replit-og.jpg differ