The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
more updates to first post
Paul Copplestonefff5b0dbf892
diff --git a/web/blog/basic-slack-clone-react-hooks.mdx b/web/blog/basic-slack-clone-react-hooks.mdxindex fb09a2e9f71..3d5dc81224a 100644--- a/web/blog/basic-slack-clone-react-hooks.mdx+++ b/web/blog/basic-slack-clone-react-hooks.mdx@@ -94,30 +94,15 @@ npm install --save @supabase/supabase-js tailwindcsslanguage="bash"/>-- `@supabase/supabase-js` - for interacting with the database. This will handle all the APIs and realtime functionality- `tailwindcss` - for making our frontend look great-### Configure our app--This step isn't required, but I always like to make a small config change so that I can import files relative to the root. For example:+### Setup all the files-```js-import MyComponent from '../../components/MyComponent' // without alias-import MyComponent from '~/components/MyComponent' // with alias```--We can do this very easily! Just copy this whole code block into your `next.config.js` file----<CustomCodeBlock-header="~/next.config.js"-code={Snippets.nextJsConfig1}-language="js"-/>-+mkdir -p lib/2 && touch lib/{store.js,helpers.js}+```## Creating the database and APIs@@ -148,10 +133,10 @@ channels .. messages`}/>-Let's create the file `./db/schema.sql` and fill it with the following SQL:+And the corresponding schema which we can save in `./db/schema.sql`:<CustomCodeBlock-header="~/db/00-schema.sql"+header="~/db/schema.sql"code={Snippets.schema}language="sql"/>@@ -165,33 +150,47 @@ This is the easiest step of all - you don't have to do anything. Supabase will i### Fire up the backend+Create the following file:+<CustomCodeBlockheader="~/docker-compose.yml"code={Snippets.dockerfile}language="yml"/>+Now run `docker-compose up`+-----## Building a basic store with React hooks-Create a file called `Store.js` in a folder `lib` (`touch ./lib/Store.js`)-and fill it with the following details:-<CustomCodeBlock-header="~/lib/Store.js"-code={Snippets.store1}-language="js"-/>+## Setting up the front end+```bash+- db+- pages+ - [channelId].js+ - index.js+- store.js+- next.config.js+- docker-compose.yml+```-## Setting up the front end+### Building a basic store with React hooks++Create a file `./Store.js`:++<CustomCodeBlock+header="~/lib/Store.js"+code={Snippets.store1}+language="js"+/>+-- create a the channels page## Making it look like Slackdiff --git a/web/blog/basic-slack-clone-react-hooks/snippets.js b/web/blog/basic-slack-clone-react-hooks/snippets.jsindex be227c0622e..e1d980ec26e 100644--- a/web/blog/basic-slack-clone-react-hooks/snippets.js+++ b/web/blog/basic-slack-clone-react-hooks/snippets.js@@ -1,58 +1,47 @@export const nextJsConfig1 = `const withSass = require('@zeit/next-sass')-const path = require("path")-// Next Config-const nextConfig = {- webpack(config) {- config.resolve.alias['~'] = path.join(__dirname, '')- return config- },-}--module.exports = withSass({ nextConfig });+module.exports withSass({+ env: {+ SUPABASE_URL: "http://localhost:8000",+ SUPABASE_KEY: "examplekey"+ }+});`-export const store1 = `-export const useStore = props => {- const [channels, setChannels] = useState(new Array())- const [messages, setMessages] = useState(new Array())- const [users] = useState(new Map())-- // Load initial data when the store is loaded- useEffect(() => {- // @todo- }, [])+export const store1 = `export const useStore = ({ channelId }) => {+ const [channels, setChannels] = useState(new Array());+ const [messages, setMessages] = useState(new Array());+ const [users] = useState(new Map());// Update the store when the user changes the "channel"- useEffect(() => {- // @todo- }, [props.channelId])+ useEffect(reloadStore, [channelId]);+ // Fetches messages for the channel and starts the channel listeners+ const reloadStore = () => {+ // @todo+ };+ // Export computed properties to use in our appreturn {- // We can export computed values here to map the authors to each messagemessages: messages.map(x => ({ ...x, author: users.get(x.user_id) })),channels: channels.sort((a, b) => a.slug.localeCompare(b.slug)),- users,- }-}+ users+ };+};`export const schema = `-- USERS-CREATE TYPE public.user_status AS ENUM ('ONLINE', 'OFFLINE');CREATE TABLE public.users (id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,username text,);--- CHANNELSCREATE TABLE public.channels (id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,slug text NOT NULL UNIQUE);--- MESSAGESCREATE TABLE public.messages (id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,@@ -60,26 +49,19 @@ CREATE TABLE public.messages (user_id bigint REFERENCES users NOT NULL,channel_id bigint REFERENCES channels NOT NULL);--- Create the Replication publication for SupabaseCREATE PUBLICATION supabase_realtime FOR ALL TABLES;---- SOME DUMMY DATAINSERT INTOpublic.users (username)VALUES- ('supabot'),- ('kiwicopple'),- ('awailas'),- ('dragarcia');-+ ('jarvis'),+ ('tonystark');INSERT INTOpublic.channels (slug)VALUES('public'),('random');-INSERT INTOpublic.messages (message, channel_id, user_id)VALUES@@ -92,7 +74,7 @@ version: '3'services:supabase:- image: supabase/supabase-dev:0.1.4+ image: supabase/supabase-dev:latestports:- "8000:8000"environment:diff --git a/web/src/css/custom.css b/web/src/css/custom.cssindex 674ca790984..6800cd9ee41 100755--- a/web/src/css/custom.css+++ b/web/src/css/custom.css@@ -781,6 +781,11 @@ a.hash-link {color: var(--ifm-color-content);font-size: 0.9rem;}+.Mermaid .graph {+ overflow-x: auto;+ margin: 0px calc(var(--ifm-spacing-horizontal) * -1);+ padding: var(--ifm-spacing-horizontal);+}.Mermaid div,.Mermaid tspan,.Mermaid g.classGroup text {