The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: updated Codeblock to work with plain markdown. works with js, jsx, python, sql and cli
Jonathan Summers-Muir8105365eedf3
diff --git a/www/_blog/2021-02-21-toadli.mdx b/www/_blog/2021-02-21-toadli.mdxdeleted file mode 100644index dae59b55334..00000000000--- a/www/_blog/2021-02-21-toadli.mdx+++ /dev/null@@ -1,41 +0,0 @@-----title: Toadli.Co-description: Learn why Zach used Supabase as part of his serverless SAAS setup.-author: rory_wilding-author_title: Supabase-author_url: https://github.com/roryw10-author_image_url: https://github.com/roryw10.png-authorURL: https://github.com/roryw10-image: toadli-og.jpg-thumb: toadli-website.jpg-tags:- - case-study-date: '02-21-2021'------Zach Waterfield is an engineer, investor, and founder of Kopa - a short term letting service with operations in over 400 cities in the USA. Zach's latest project, Toad, is an easy-to-use link shortening tool with simple APIs, aimed to empower low-coders. Toad provides a simple dashboard, analytics, and API designed with low-coders in mind.--Learn why Zach used Supabase as part of his serverless SAAS setup.--### Toad APIs for low Coders--Zach loves link shorteners. However, for low-coders, link shorteners tend to have cumbersome APIs limiting their utility. He wanted to build a link shortening tool with simple APIs that are simple for no-coders to use.--### The power of a serverless Supa-stack--Zach started this project with a low-management overhead in mind. He needed a robust and scalable stack that doesn't need refactoring when his service user volume grows. Zach knew that a back-end as-a-service abstracts away many of the dev-ops tasks, such as provisioning server instances and setting up databases. From experience, he knew that Firebase would be too cumbersome.--Zach decided that combining Supabase, Lambda functions, Next.Js, and Vercel would be the perfect Supa-stack to achieve his goal of low-management overhead. This setup removes significant dev-ops headaches with no need to think about continuous integration - when he wants to make a change, it is good to go. As a bonus, this setup is virtually free until he reaches significant user volumes.--### Build it once, use it forever--Once Zach got to work, he continued to be impressed with how quickly he built and deployed a service that is ready to scale through the power of his Supa-stack. Zach also realised he now has a boilerplate project that he can customise for any future SAAS service. He has a stack that is scalable, reusable, and low-management. Toad has early paying customers, and traffic volumes are increasing as low-coders become aware of how easy Toad APIs are to use.--<Quote img="zach-waterfield.png" caption="Zach Waterfield - Toad">- Full Serverless is an amazing developer experience. You can get high-quality results fast,- especially when Supabase abstracts away all the back-end headaches.-</Quote>--### Spent more time creating and less time managing back ends--Thanks to Supabase, Zach is able to focus on the creative process and launch services like Toad with all the functionality he wants to offer. He has peace of mind that his stack is low-management and will scale as his project continues to gain traction.diff --git a/www/_blog/2021-02-27-cracking-postgres-interview.mdx b/www/_blog/2021-02-27-cracking-postgres-interview.mdxnew file mode 100644index 00000000000..e6922142fa5--- /dev/null+++ b/www/_blog/2021-02-27-cracking-postgres-interview.mdx@@ -0,0 +1,157 @@+---+title: Cracking PostgreSQL Interview Questions+description: Understand the top PostgreSQL Interview Questions+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/elephants.png+tags:+ - SQL+ - Postgres+date: '02-27-2021'+---++There are plenty of resources out there for preparing for PostgreSQL interview questions. Most posts are for technical interviews with a focus on PostgreSQL, however many just cover the basics and the advanced resources often conflate transactional SQL with analytical SQL (WINDOW/RANK functions, aggregates etc.).++Here, we're going to focus on PostgreSQL interview questions that are aimed to understand the transactional side of PostgreSQL, and offer some areas that you may want to go a little deeper on in order to really impress your interviewer (and more importantly, become a kick-ass software engineer).++## 1. Modeling++### Know how to model 1-M, M-M, 1-1 relationships. And know how to use foreign keys.++A review of [database normalization](https://ocw.mit.edu/courses/civil-and-environmental-engineering/1-264j-database-internet-and-systems-integration-technologies-fall-2013/lecture-notes-exercises/MIT1_264JF13_lect_10.pdf) is a great place to start when thinking about how to correctly model relationships. However if you don't have the time to read through lecture notes, head over to [DBDesigner](https://app.dbdesigner.net/designer/schema/guest_template) and inspect their example schema. The table StudentCourses is a great example of how to model a Many-to-Many relationship, by using a join table. (side note: you can export these visual schemas to SQL using Ctrl+E). Modelling your data correctly is arguably the most important part of any software project, writing applications becomes a breeze if you can get the data layer right.++### Know how to use pg rich type system: [arrays](https://www.postgresql.org/docs/current/arrays.html), [domains](https://www.postgresql.org/docs/current/domains.html), [JSONB](https://www.postgresql.org/docs/13/datatype-json.html), [timestamptz](https://www.postgresql.org/docs/current/functions-datetime.html), [enums](https://www.postgresql.org/docs/13/datatype-enum.html)++Postgres has tons of useful types beyond the basics, knowing how to use them will show you can leverage the true power of Postgres. JSONB for example can be incredibly useful for storing non-structured data, which you can query using syntax like:++```sql+-- grades = {'geography': 'A', 'history': 'B', 'postgres': 'A++'}+SELECT * FROM students WHERE grades->>'geography' = 'A';+```++### Know about namespacing with SCHEMAs++In Supabase for example we keep system schemas such as `extensions` and `auth` in separate schemas so that we don't pollute the default `public` schema.++## 2. INDEXes++### Know how speed up queries with indexes.++The art of indexing in Postgres could fill an entire book. In some circumstances it can happen that a bad index is worse for performance than no index, so it's worth spending a little time to learn some of the common strategies.++An index can be simple, for example, if your students table is most frequently queried on surname alone, you create an index:++```sql+CREATE INDEX idx_students_surname+ON students(surname);+```++The default index type used here is `btree` (you could have specified this as `USING btree`), but there are other types of indexes, such as `BRIN`, `GiST`, `GIN`, `hash`, and more. Readers wanting to go deeper may also want to explore [Partial](https://www.postgresql.org/docs/current/indexes-partial.html) or [Multicolumn](https://www.postgresql.org/docs/13/indexes-multicolumn.html) Indexes.++### Know how to analyze with EXPLAIN ANALYZE++Running++```sql+EXPLAIN (ANALYZE) SELECT *+FROM students+WHERE surname = 'Krobb';+```++Before and after adding your index will show you the difference in approach the query planner took to finding your data. Note that using EXPLAIN alone will give us estimated plan costs. When used together with ANALYZE like: `EXPLAIN (ANALYZE)` you will receive both estimated and actual costs.++## 3. VIEWs++### Know how to create different representations of data with [VIEWs](https://supabase.io/blog/2020/11/18/postgresql-views).++We might create a VIEW `transcripts` which pulls out data from `students`, `courses`, and `grades`. It's useful for security, and logical abstractions. Check out our longer post on VIEWs here: [https://supabase.io/blog/2020/11/18/postgresql-views](https://supabase.io/blog/2020/11/18/postgresql-views). Some purists may argue that you should always query VIEWs and never TABLEs.++### Know about Autoupdatable views.++If a VIEW is named as the target relation in an INSERT, UPDATE, or DELETE and only SELECTs from a single base relation, then the underlying subquery is automatically rewritten to update the underlying base relation instead.++### Limitations on VIEWs++One example of a limitation is when a VIEW is not Autoupdatable. This happens when the VIEW does not SELECT from a single base relation. If the user does not specify an INSTEAD OF trigger that upgrades the underlying query, then an error will be thrown, since the executor cannot update a view as such.++## 4. ROLEs++### Know how to secure their database. Permissions at the table, column, row level.++All databases have different user types, your client for example doesn't usually need the ability to create and drop schemas, but your DB admin does. You should play around with [creating roles](https://www.postgresql.org/docs/current/database-roles.html), and [granting](https://www.postgresql.org/docs/current/role-membership.html) various permissions.++### Know about [ROLEs](https://www.postgresql.org/docs/13/sql-createrole.html), application ROLEs, the PUBLIC role, and [GRANTs](https://www.postgresql.org/docs/current/sql-grant.html)++In Postgres, the special “role” name PUBLIC can be used to grant a privilege to every role on the system. For example, if you want to grant insert access to all users on table students:++```sql+GRANT INSERT ON students TO PUBLIC;+```++### Know how to do RLS - Policies++We use Row Level Security in Supabase as a way to grant/restrict access on a row level basis. For example if you're writing a Discord clone, perhaps only a given user should be able to write their own messages:++```sql+CREATE POLICY "Individuals can only write their own messages." ON messages FOR+ INSERT WITH CHECK (auth.uid() = user_id);++-- auth.uid() is a function provided by Supabase which plucks the uid out+-- of the JWT sent along with an API request more on this here:+-- https://www.youtube.com/watch?v=0LvCOlELs5U+```++## 5. FUNCTIONs++### Know how to do business logic on SQL/[PLPGSQL](https://www.postgresql.org/docs/current/plpgsql-overview.html#PLPGSQL-ADVANTAGES)++PL/pgSQL is a procedural programming language that can be used to write functions inside of your database. It can be useful for making [remote procedure calls](https://supabase.io/docs/client/rpc) from an API. You can go as deep as you want here, since it's an entire programming language, but understanding the basics will really go a long way, and give you super powers when working with your data.++You can use FUNCTIONs in combination with TRIGGERs to do cool stuff like have auto-updating `updated_at` columns on your data:++```sql+-- a function that sets the updated_at value to now()+CREATE FUNCTION set_updated_at()+RETURNS TRIGGER AS $$+BEGIN+ new.updated_at = now();+ RETURN NEW;+END;+$$ LANGUAGE plpgsql;++-- a trigger that fires when students table is updated+CREATE TRIGGER handle_updated_at+ BEFORE UPDATE ON students+ FOR EACH ROW+ EXECUTE PROCEDURE set_updated_at();+```++### Thinks in SETs when doing logic++Whilst PL/pgSQL does have [loops](https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-CONTROL-STRUCTURES-LOOPS) and [cursors](https://www.postgresql.org/docs/current/plpgsql-cursors.html), there is usually a faster and more legible pure SQL based solution available using JOIN/UNION etc. So it's important to become well acquainted with thinking in these terms.++### Know how to use [CTEs](https://www.postgresqltutorial.com/postgresql-cte/)++Common table expressions are temporary or intermediate result sets. They can make your queries more readable and even enable recursion. The typical form is:++```sql+WITH ten_strumpers AS (+ SELECT id, first_name+ FROM students+ WHERE surname = 'Strumper'+ ORDER BY first_name+ LIMIT 10+)+SELECT id+FROM ten_strumpers+WHERE first_name LIKE "S%";+```++If you can reason about most of the topics in this post then you'll be in a very strong position to impress with your answers to PostgreSQL interview questions. As with all programming topics however, the real learning starts when you put these things into practice. At Supabase we offer a very very fast (the fastest?) way to spin up a PostgreSQL database and start querying it, and our browser based SQL editor is getting more powerful every day.++[Get started on Supabase for free here](https://app.supabase.io)++Thanks Steve Chavez for providing all the good bits of this post :)diff --git a/www/_blog/2021-03-02-supabase-beta-february-2021.mdx b/www/_blog/2021-03-02-supabase-beta-february-2021.mdxnew file mode 100644index 00000000000..18530e485af--- /dev/null+++ b/www/_blog/2021-03-02-supabase-beta-february-2021.mdx@@ -0,0 +1,111 @@+---+title: Supabase Beta February 2021+description: One year of building.+author: Paul Copplestone+author_title: Supabase+author_url: https://github.com/kiwicopple+author_image_url: https://github.com/kiwicopple.png+authorURL: https://github.com/kiwicopple+image: /img/release-feb-2021.jpg+tags:+ - release-notes+date: '03-02-2021'+---++Supabase is an open source Firebase alternative. We've now been building for one year. Here's what we released last month.++<!--truncate-->++### Quick demo++Watch a full demo:++<iframe+ className="w-full video-with-border"+ width="640"+ height="385"+ src="https://www.youtube-nocookie.com/embed/h-ses99G45g"+ frameBorder="1"+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"+ allowFullScreen+></iframe>++### Dashboard Sidebars++We've improved the UX of our Dashboard with sidebars in every section, including the Table view, the Auth section, and the SQL Editor.++++### SQL Autocomplete++Writing SQL just got 10x easier. We added autocomplete to the SQL editor, including table & column suggestions.++<video width="99%" autoPlay="autoplay" muted playsInline controls={true}>+ <source src="/img/blog/feb/autocomplete.mp4" type="video/mp4" muted playsInline />+</video>++### Auth Redirects++Redirect your users to specific route within your site on [`signIn()`](https://supabase.io/docs/client/auth-signin#sign-in-with-redirect) and [`signUp()`](https://supabase.io/docs/client/auth-signup#sign-up-with-redirect).++++### Replication management++We added a page to the Database section for managing Postgres Replication. It's still basic, but you can use it to manage your realtime API - choosing which tables are enabled, and which events to send.++++### Learning Resources++We've released a new [Resources](https://supabase.io/docs/resources) section in our docs, as well as two new Auth modules: [GoTrue Overview](https://supabase.io/docs/learn/auth-deep-dive/auth-gotrue) and [Google OAuth](https://supabase.io/docs/learn/auth-deep-dive/auth-google-oauth).++++### New Region++Launch your database in South Africa.++++### Kaizen++- We filled up our [Examples](https://supabase.io/docs/guides/examples) page with a lot of new content.+- We released a [Docker Compose](https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml) file for running Supabase locally. This will be used in our upcoming CLI.+- We have a couple of pending RFCs which you may want to participate in:+ - [Planning our CLI and Local Development](https://github.com/supabase/cli/pull/2)+ - [Connection Pooling on Supabase](https://github.com/supabase/postgres/blob/rfc/connection_pooling/rfcs/0001-connection-pooling.md)++### Community++One of the community, [@ftonato](https://github.com/ftonato), has built an amazing [example](https://github.com/supabase/supabase/tree/master/examples/with-stencil) that shows how to use Supabase with [Stencil](https://stenciljs.com/) (a Web Component compiler built by they [Ionic](https://ionicframework.com/) team.)++[Check it out!](https://github.com/supabase/supabase/tree/master/examples/with-stencil)++++- @kiwicopple on the LogRocket Podcast. [Link](https://podrocket.logrocket.com/9)+- @bdougie Livestream: More Fullstack React w RedwoodJS + Supabase. [Link](https://www.twitch.tv/videos/907698954)+- @gbibeaul created `useSupabase`: Supabase React Hooks. [GitHub](https://www.npmjs.com/package/use-supabase)++We hit 6000 GitHub stars on [GitHub](https://github.com/supabase/supabase)++++<small>+ Source: <a href="https://repository.surf/supabase">repository.surf/supabase</a>+</small>++### Coming next++Waiting for Supabase Storage? Here's a sneak peek for the upcoming Launch Week at the end of March.++++### Get started++- Start using Supabase today: [app.supabase.io](https://app.supabase.io/)+- Make sure to [star us on GitHub](https://github.com/supabase/supabase)+- Follow us [on Twitter](https://twitter.com/supabase_io)+- Subscribe to our [YouTube channel](https://www.youtube.com/channel/UCNTVzV1InxHV-YR0fSajqPQ)+- Become a [sponsor](https://github.com/sponsors/supabase)diff --git a/www/_blog/2021-03-05-postgres-as-a-cron-server.mdx b/www/_blog/2021-03-05-postgres-as-a-cron-server.mdxnew file mode 100644index 00000000000..39b0e15f5c8--- /dev/null+++ b/www/_blog/2021-03-05-postgres-as-a-cron-server.mdx@@ -0,0 +1,202 @@+---+title: Postgres as a CRON Server+description: Running repetitive tasks with your Postgres database.+author: Paul Copplestone+author_title: Supabase+author_url: https://github.com/kiwicopple+author_image_url: https://github.com/kiwicopple.png+authorURL: https://github.com/kiwicopple+image: /img/blog/supabase-postgres-cron.png+tags:+ - postgres+date: '03-05-2021'+---++A Supabase user asked recently if they can trigger a webhook periodically. We haven't yet released Functions yet, so we checked whether it's possible with Postgres.++It is. Here's how.++<!--truncate-->++### What's cron?++A "cron job" is a script[^1] that runs periodically at fixed times, dates, or intervals. Traditionally you'd set it up on a Linux server. An example might be an hourly script that downloads emails to your computer.++[^1]: Not necessarily a script. The cron is really a scheduler which triggers a job (of some sort, usually a bash script).++These days, cron jobs are set up on a remote servers and in the cloud to run internet-related tasks. Like checking an endpoint every hour, or scraping a website every day.++### Postgres + cron++Postgres has "extensions" which allow you to, well, extend the database with "non-core" features. Extensions essentially turn Postgres into an application server.++The team at [Citus](https://github.com/citusdata) created [`pg_cron`](https://github.com/citusdata/pg_cron) to run periodic jobs within your Postgres database.++#### Enabling the extension++If you're using a cloud-hosted Postgres database, make sure that `pg_cron` is installed first. The easiest way to do this is to run this command:++```sql+select name, comment, default_version, installed_version+from pg_available_extensions+where name = 'pg_cron';+```++If it returns a result then the extension is supported and you can turn it on by running:++```sql+create extension if not exists pg_cron;+```++If you're using Supabase you can also enable it in the Dashboard.++++### Postgres + webhooks++The Supabase customer wanted to call external endpoints every day. How would we do this? Another extension of course. This time we're going to use [pgsql-http](https://github.com/pramsey/pgsql-http) by [@pramsey](https://github.com/pramsey). Using the same technique, we can enable the extension (if it exists in your cloud provider).++```sql+create extension if not exists http;+```++This extension can now be used for [sending](https://github.com/pramsey/pgsql-http#functions) `GET`, `POST`, `PATCH`, and `DELETE` requests.++For example, this function would get all the people in Star Wars (using the [Star Wars API](https://swapi.dev)):++```sql+select content::json->'results'+from http_get('https://swapi.dev/api/people');+```++### Postgres + cron + webhooks++Now the fun stuff. For this example we're going to call [webhook.site](https://webhook.site) every minute with the payload `{ "hello": "world" }`.++Here's the code (with comments `--like this`).++```sql+select+ cron.schedule(+ 'webhook-every-minute', -- name of the cron job+ '* * * * *', -- every minute+ $$+ select status+ from+ http_post(+ 'https://webhook.site/223c8a43-725b-4cbd-b1fe-d0da73353a6b', -- webhook URL, replace the ID(223c8..) with your own+ '{"hello": "world"}', -- payload+ 'application/json'+ )+ $$+ );+```++Now when we see that the payload is sent every minute, exactly on the minute.++++And that's it! We've built a cron webhook. Breaking down the code example above we have 2 key parts:++#### POSTing data++This is the part that sends the data to the website:++```sql+select status+from+ http_post(+ 'https://webhook.site/223c8a43-725b-4cbd-b1fe-d0da73353a6b', -- webhook URL+ '{"hello": "world"}', -- payload+ 'application/json'+ )+```++#### Scheduling the job++The HTTP function is wrapped with the CRON scheduler:++```sql+select+ cron.schedule(+ 'cron-name', -- name of the cron job+ '* * * * *', -- every minute+ $$+ -- Put your code between two dollar signs so that you can create full statements.+ -- Alternatively, you can write you code in a Postgres Function and call it here.+ $$+ );+```++The second parameter uses cron syntax:++```sh+ ┌───────────── min (0 - 59)+ │ ┌────────────── hour (0 - 23)+ │ │ ┌─────────────── day of month (1 - 31)+ │ │ │ ┌──────────────── month (1 - 12)+ │ │ │ │ ┌───────────────── day of week (0 - 6) (0 to 6 are Sunday to+ │ │ │ │ │ Saturday, or use names; 7 is also Sunday)+ * * * * *+```++If you're unfamiliar with the cron syntax, useful shortcuts can be found on [crontab.guru](https://crontab.guru/)++```sh+* * * * * # every minute+*/5 * * * * # every 5th minute+0 * * * * # every hour+0 0 * * * # every day+```++#### Managing your cron jobs++To see a list of all your cron jobs, run:++```sql+select * from cron.job;+```++And if you need to see the results of each cron iterations, you can find them in `cron.job_run_details`:++```sql+select * from cron.job_run_details;+```++To stop a running cron job, you can run:++```sql+select cron.unschedule('webhook-every-minute'); -- pass the name of the cron job+```++### What can I do with this?++There are plenty use-cases for this. For example:++- **Sending welcome emails.** If you use an email provider with an HTTP API, then you batch emails to that service. Write a function that `selects` all your signups yesterday, then sends them to your favourite transactional email service. Schedule it every day to run at midnight.+- **Aggregating data.** If you're providing analytical data, you might want to aggregate it into time periods for faster querying (which serves a similar purpose as a [Materialized View](https://supabase.io/blog/2020/11/18/postgresql-views#materialized-views-vs-conventional-views)).+- **Deleting old data.** Need to free up space? Run a scheduled job to delete data you no longer need.++See a detailed list in the [`pg_cron` README](https://github.com/citusdata/pg_cron#example-use-cases).++## Addendum++### Postgres background workers++You might have noticed [this](https://github.com/pramsey/pgsql-http#why-this-is-a-bad-idea) notice the warning at the bottom of the `http` readme:++> "What happens if the web page takes a long time to return?" Your SQL call will just wait there until it does. Make sure your web service fails fast.++Luckily pg_cron implements [Background Workers](https://paquier.xyz/postgresql-2/postgres-9-3-feature-highlight-custom-background-workers/):++> Care is taken that these extra processes do not interfere with other postmaster tasks: only one such process is started on each ServerLoop iteration. This means a large number of them could be waiting to be started up and postmaster is still able to quickly service external connection requests.++This means that even if your endpoint takes a long time to return, it's not going to be blocking your core Postgres functions. Either way, you should probably only call endpoints that will return a response quickly, or set the http extension to fail fast (`http.timeout_msec = 300`).++If you're familiar with `C`, you could also help `@pramsey` to implement async functions: https://github.com/pramsey/pgsql-http/issues/105++### Should I use Postgres as a cron server?++There are plenty of ways to run cron jobs these days. You can trigger them from your local machine. You can install them on a VPS. You can schedule Serverless functions. You can use a paid service. You can use GitHub Actions.++Is Postgres the best place to put your cron jobs? `¯\_(ツ)_/¯`. Postgres databases are free on Supabase and since it takes only one minute to [get started](https://app.supabase.io/), why not make your next cron server a Postgres database?diff --git a/www/_blog/2021-03-08-toad-a-link-shorterner-with-simple-apis-for-low-coders.mdx b/www/_blog/2021-03-08-toad-a-link-shorterner-with-simple-apis-for-low-coders.mdxnew file mode 100644index 00000000000..56510601922--- /dev/null+++ b/www/_blog/2021-03-08-toad-a-link-shorterner-with-simple-apis-for-low-coders.mdx@@ -0,0 +1,41 @@+---+title: Toad, a link shorterner with simple APIs for low-coders+description: An easy-to-use link shortening tool with simple APIs+author: rory_wilding+author_title: Supabase+author_url: https://github.com/roryw10+author_image_url: https://github.com/roryw10.png+authorURL: https://github.com/roryw10+image: /toadli-og.png+tags:+ - supabase+ - case-study+date: '03-08-2021'+---++Zach Waterfield is an engineer, investor, and founder of Kopa - a short term furnished rental marketplace with operations in over 400 cities in the USA. Zach's latest project, [Toad](https://toadli.co/), is an easy-to-use link shortening tool with simple APIs, aimed to empower low-coders. Toad provides a simple dashboard, analytics, and API designed with low-coders in mind.++Learn why Zach used Supabase as part of his serverless SAAS setup.++### Toad APIs for low Coders++Zach loves link shorteners. However, for low-coders, link shorteners tend to have cumbersome APIs limiting their utility. He wanted to build a link shortening tool with simple APIs that are simple for no-coders to use.++## The power of a serverless Supa-stack++Zach started this project with a low-management overhead in mind. He needed a robust and scalable stack that doesn't need refactoring when his service user volume grows. Zach knew that a back-end as-a-service abstracts away many of the dev-ops tasks, such as provisioning server instances and setting up databases. From experience, he knew that Firebase would be too cumbersome.++Zach decided that combining Supabase, Lambda functions, Next.js, TailwindCSS, and Vercel would be the perfect Supa-stack to achieve his goal of low-management overhead. This setup removes significant dev-ops headaches with no need to think about continuous integration - when he wants to make a change, it is good to go. As a bonus, this setup is virtually free until he reaches significant user volumes.++### Build it once, use it forever++Zach was surprised how rapidly he was able to build and deploy Toadli. He now has a template project that he plans to customise for future SaaS services. Zach has a stack that is scalable, reusable, and low-management. Toad has early paying customers, and traffic volumes are increasing as low-coders become aware of how easy Toad APIs are to use.++<Quote img="zach-waterfield.png" caption="Zach Waterfield - Toad">+ Full Serverless is an amazing developer experience. You can get high-quality results fast,+ especially when Supabase abstracts away all the back-end headaches+</Quote>++## Spend more time creating and less time managing back ends++Thanks to Supabase, Zach is able to focus on the creative process and launch services like [Toad](https://toadli.co/) with all the functionality he wants to offer. He has peace of mind that his stack is low-management and will scale as his project continues to gain traction.diff --git a/www/_blog/2021-03-11-using-supabase-replit.mdx b/www/_blog/2021-03-11-using-supabase-replit.mdxnew file mode 100644index 00000000000..9648900267b--- /dev/null+++ b/www/_blog/2021-03-11-using-supabase-replit.mdx@@ -0,0 +1,134 @@+---+title: Using Supabase in Replit+description: Free hosted relational database from within your node.js repl+author: awalias+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+date: '03-11-2021'+---++[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++++Select node.js, give it a name, and click Create repl++++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...'+)+```++++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.++++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/www/components/CodeBlock/CodeBlock.tsx b/www/components/CodeBlock/CodeBlock.tsxindex 534783cbfa4..c2364d7873a 100644--- a/www/components/CodeBlock/CodeBlock.tsx+++ b/www/components/CodeBlock/CodeBlock.tsx@@ -1,41 +1,50 @@import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'-import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'import monokaiCustomTheme from 'data/CodeEditorTheme'import CodeBlockStyles from './CodeBlock.module.css'import { Button, IconCopy } from '@supabase/ui'import CopyToClipboard from 'react-copy-to-clipboard'+import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'+import jsx from 'react-syntax-highlighter/dist/cjs/languages/prism/jsx'+import py from 'react-syntax-highlighter/dist/cjs/languages/hljs/python'+import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'+interface Props {lang: 'js'- code: 'string'startingLineNumber?: numberhideCopy?: boolean+ className?: string+ children?: string}+function CodeBlock(props: Props) {- // const {- // lang = 'js',- // code,- // startingLineNumber = 1- // } = props+ let lang = props.lang+ ? props.lang+ : props.className+ ? props.className.replace('language-', '')+ : 'js'+ // force jsx to be js highlighted+ if (lang === 'jsx') lang = 'js'- SyntaxHighlighter.registerLanguage('javascript', js)+ SyntaxHighlighter.registerLanguage('js', js)+ SyntaxHighlighter.registerLanguage('jsx', jsx)+ SyntaxHighlighter.registerLanguage('py', py)+ SyntaxHighlighter.registerLanguage('sql', sql)return (<div className="relative"><SyntaxHighlighter- // startingLineNumber={startingLineNumber}- language="javascript"+ language={lang}style={monokaiCustomTheme}className={CodeBlockStyles['code-block']}customStyle={{padding: 0,- // paddingTop: '32px',fontSize: 12,lineHeight: 1.2,borderTop: '1px solid #393939',background: '#181818',}}- showLineNumbers+ showLineNumbers={lang === 'cli' ? false : true}lineNumberContainerStyle={{paddingTop: '128px',}}@@ -50,11 +59,11 @@ function CodeBlock(props: Props) {paddingBottom: '4px',}}>- {props.code}+ {props.children}</SyntaxHighlighter>{!props.hideCopy && (<div className="absolute right-2 top-2 dark">- <CopyToClipboard text={props.code}>+ <CopyToClipboard text={props.children}><Button type="outline" icon={<IconCopy />}>Copy</Button>diff --git a/www/pages/blog/[slug].module.css b/www/pages/blog/[slug].module.cssindex 67fe51f6dec..ac4ba7f27cf 100644--- a/www/pages/blog/[slug].module.css+++ b/www/pages/blog/[slug].module.css@@ -61,3 +61,8 @@.article {@apply mb-16;}++.article > div > pre {+ padding: 0;+ background: none;+}diff --git a/www/pages/blog/[slug].tsx b/www/pages/blog/[slug].tsxindex a7f25244f7f..9661cddfab6 100644--- a/www/pages/blog/[slug].tsx+++ b/www/pages/blog/[slug].tsx@@ -4,7 +4,7 @@ import { useRouter } from 'next/router'import DefaultLayout from '~/components/Layouts/Default'import { NextSeo } from 'next-seo'-import { getAllPostSlugs, getPostdata, getSortedPosts, getLastPost } from '~/lib/posts'+import { getAllPostSlugs, getPostdata, getSortedPosts } from '~/lib/posts'import { generateReadingTime } from '~/lib/helpers'import ReactMarkdown from 'react-markdown'import authors from 'lib/authors.json'@@ -21,11 +21,18 @@ import Link from 'next/link'// import all components used in blog articles here// for instance, if you use a button, you must add `Button` in the components object below.-const components = { CodeBlock, Quote }+const components = {+ CodeBlock,+ Quote,+ code: (props: any) => {+ return <CodeBlock {...props} />+ },+}// plugins for next-mdx-remoteconst gfm = require('remark-gfm')const slug = require('rehype-slug')+const highlight = require('remark-highlight.js')// table of contents extractorconst toc = require('markdown-toc')diff --git a/www/public/rss.xml b/www/public/rss.xmlindex b70eede9e6f..8d97597e0ac 100644--- a/www/public/rss.xml+++ b/www/public/rss.xml@@ -5,7 +5,7 @@<link>https://supabase.io</link><description>Latest news from Supabase</description><language>en</language>- <lastBuildDate>Invalid Date</lastBuildDate>+ <lastBuildDate>Wed, 10 Mar 2021 16:00:00 GMT</lastBuildDate><atom:link href="https://supabase.io/blog/rss.xml" rel="self" type="application/rss+xml"/><item>@@ -13,7 +13,7 @@<title>Using Supabase in Replit</title><link>https://supabase.io/blog/2021-03-11-using-supabase-replit</link><description>Free hosted relational database from within your node.js repl</description>- <pubDate>Invalid Date</pubDate>+ <pubDate>Wed, 10 Mar 2021 16:00:00 GMT</pubDate></item><item>@@ -21,7 +21,7 @@<title>Toad, a link shorterner with simple APIs for low-coders</title><link>https://supabase.io/blog/2021-03-08-toad-a-link-shorterner-with-simple-apis-for-low-coders</link><description>An easy-to-use link shortening tool with simple APIs</description>- <pubDate>Invalid Date</pubDate>+ <pubDate>Sun, 07 Mar 2021 16:00:00 GMT</pubDate></item><item>@@ -29,7 +29,7 @@<title>Postgres as a CRON Server</title><link>https://supabase.io/blog/2021-03-05-postgres-as-a-cron-server</link><description>Running repetitive tasks with your Postgres database.</description>- <pubDate>Invalid Date</pubDate>+ <pubDate>Thu, 04 Mar 2021 16:00:00 GMT</pubDate></item><item>@@ -37,7 +37,7 @@<title>Supabase Beta February 2021</title><link>https://supabase.io/blog/2021-03-02-supabase-beta-february-2021</link><description>One year of building.</description>- <pubDate>Invalid Date</pubDate>+ <pubDate>Mon, 01 Mar 2021 16:00:00 GMT</pubDate></item><item>@@ -45,15 +45,7 @@<title>Cracking PostgreSQL Interview Questions</title><link>https://supabase.io/blog/2021-02-27-cracking-postgres-interview</link><description>Understand the top PostgreSQL Interview Questions</description>- <pubDate>Invalid Date</pubDate>-</item>--<item>- <guid>https://supabase.io/blog/2021-02-21-toadli</guid>- <title>Toadli.Co</title>- <link>https://supabase.io/blog/2021-02-21-toadli</link>- <description>Learn why Zach used Supabase as part of his serverless SAAS setup.</description>- <pubDate>Sat, 20 Feb 2021 16:00:00 GMT</pubDate>+ <pubDate>Fri, 26 Feb 2021 16:00:00 GMT</pubDate></item><item>