The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
app: add auth and styling
thorwebdevbec9a25389c7
diff --git a/examples/edge-functions/app/src/App.js b/examples/edge-functions/app/src/App.jsindex 9ae917ee3dd..f08f60348e8 100644--- a/examples/edge-functions/app/src/App.js+++ b/examples/edge-functions/app/src/App.js@@ -1,19 +1,15 @@import React, { useState } from 'react'-import { Button, Typography, Select } from '@supabase/ui'+import { Auth, Button, Typography, Select } from '@supabase/ui'import JSONInput from 'react-json-editor-ajrm'import locale from 'react-json-editor-ajrm/locale/en'-import { createClient } from '@supabase/supabase-js'+import { supabase } from './utils/supabaseClient'import { functionsList } from './functionsList'-const { Title, Text, Link } = Typography-const supabase = createClient(- process.env.REACT_APP_SUPABASE_URL ?? 'http://localhost:54321',- process.env.REACT_APP_SUPABASE_ANON_KEY ??- 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs'-)+const { Title, Text } = Typographyconst sampleObject = { name: 'world' }function App() {+ const { user } = Auth.useUser()const [supaFunction, setSupaFunction] = useState(functionsList[0])const [requestJson, setRequestJson] = useState(sampleObject)const [responseJson, setResponseJson] = useState({})@@ -28,35 +24,60 @@ function App() {}return (- <div className="">- <Title level={2}>Supabase Egde Functions Test Client</Title>- <div>- <Title level={3}>Request</Title>- <Title level={4}>Function</Title>- <Select onChange={(e) => setSupaFunction(e.target.value)}>- {functionsList.map((func) => (- <Select.Option value={func} key={func}>- {func}- </Select.Option>- ))}- </Select>- <Text>- Note: when using locally, this selection doesn't have any effect and the function that's- currently being served via the CLI is called instead.- </Text>- <Title level={4}>Body</Title>- <JSONInput- onChange={({ jsObject }) => setRequestJson(jsObject)}- placeholder={sampleObject}- locale={locale}- height="100"- />- <Title level={4}>Send request:</Title>- <Button onClick={invokeFunction}>Submit</Button>- </div>- <div>- <Title level={3}>Response</Title>- <pre>{JSON.stringify(responseJson, null, 2)}</pre>+ <div className="p-2">+ <Title level={2} className="mb-2">+ Supabase Egde Functions Test Client+ </Title>+ <div className="grid grid-cols-1 md:grid-cols-2">+ <div className="p-2">+ <Title level={3} className="mb-2">+ Request+ </Title>+ <Title level={4}>Function</Title>+ <Select onChange={(e) => setSupaFunction(e.target.value)}>+ {functionsList.map((func) => (+ <Select.Option value={func} key={func}>+ {func}+ </Select.Option>+ ))}+ </Select>+ <Text className="mb-2">+ Note: when using locally, this selection doesn't have any effect and the function that's+ currently being served via the CLI is called instead.+ </Text>+ <Title level={4} className="mb-2">+ Body+ </Title>+ <JSONInput+ onChange={({ jsObject }) => setRequestJson(jsObject)}+ placeholder={sampleObject}+ locale={locale}+ height="100"+ width="100%"+ />+ <Button className="mt-2" onClick={invokeFunction}>+ Invoke Function+ </Button>+ </div>+ <div className="p-2">+ <Title level={3} className="mb-2">+ Response+ </Title>+ <pre className="p-2 bg-gray-300 ">{JSON.stringify(responseJson, null, 2)}</pre>+ </div>+ <div className="p-2">+ <Title level={3} className="mb-2">+ Log in to see RLS in action+ </Title>+ {user ? (+ <div>+ <Title level={4} className="mb-2">{`Logged in as ${user.email}`}</Title>+ <Button onClick={() => supabase.auth.signOut()}>Sign out</Button>+ </div>+ ) : (+ <Auth supabaseClient={supabase} />+ )}+ </div></div></div>)diff --git a/examples/edge-functions/app/src/index.js b/examples/edge-functions/app/src/index.jsindex 606a3cf44ec..3a641dd416d 100644--- a/examples/edge-functions/app/src/index.js+++ b/examples/edge-functions/app/src/index.js@@ -2,10 +2,14 @@ import React from 'react'import ReactDOM from 'react-dom'import './index.css'import App from './App'+import { Auth } from '@supabase/ui'+import { supabase } from './utils/supabaseClient'ReactDOM.render(<React.StrictMode>- <App />+ <Auth.UserContextProvider supabaseClient={supabase}>+ <App />+ </Auth.UserContextProvider></React.StrictMode>,document.getElementById('root'))diff --git a/examples/edge-functions/app/src/utils/supabaseClient.js b/examples/edge-functions/app/src/utils/supabaseClient.jsnew file mode 100644index 00000000000..d369fec80dc--- /dev/null+++ b/examples/edge-functions/app/src/utils/supabaseClient.js@@ -0,0 +1,7 @@+import { createClient } from '@supabase/supabase-js'++export const supabase = createClient(+ process.env.REACT_APP_SUPABASE_URL ?? 'http://localhost:54321',+ process.env.REACT_APP_SUPABASE_ANON_KEY ??+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs'+)