Skip to content

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

Chore/add vite to connect UI (#22606)

Terry Sutton72d5f656b541
diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts b/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts
index 9814e1e6dfe..00f6e5aebd0 100644
--- a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts
+++ b/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts
@@ -63,10 +63,30 @@ export const FRAMEWORKS: ConnectionType[] = [
guideLink: 'https://supabase.com/docs/guides/getting-started/quickstarts/reactjs',
children: [
{
- key: 'supabasejs',
- label: 'Supabase-js',
- children: [],
- icon: 'supabase',
+ key: 'create-react-app',
+ label: 'Create React App',
+ icon: 'react',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'supabase-js',
+ icon: 'supabase',
+ children: [],
+ },
+ ],
+ },
+ {
+ key: 'vite',
+ label: 'Vite',
+ icon: 'vite',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
},
],
},
diff --git a/apps/studio/components/interfaces/Home/Connect/content/react/supabasejs/content.tsx b/apps/studio/components/interfaces/Home/Connect/content/react/create-react-app/supabasejs/content.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Home/Connect/content/react/supabasejs/content.tsx
rename to apps/studio/components/interfaces/Home/Connect/content/react/create-react-app/supabasejs/content.tsx
diff --git a/apps/studio/components/interfaces/Home/Connect/content/react/vite/supabasejs/content.tsx b/apps/studio/components/interfaces/Home/Connect/content/react/vite/supabasejs/content.tsx
new file mode 100644
index 00000000000..86ad9bb36fe
--- /dev/null
+++ b/apps/studio/components/interfaces/Home/Connect/content/react/vite/supabasejs/content.tsx
@@ -0,0 +1,80 @@
+import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
+
+import {
+ ConnectTabs,
+ ConnectTabTrigger,
+ ConnectTabTriggers,
+ ConnectTabContent,
+} from 'components/interfaces/Home/Connect/ConnectTabs'
+import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
+
+const ContentFile = ({ projectKeys }: ContentFileProps) => {
+ return (
+ <ConnectTabs>
+ <ConnectTabTriggers>
+ <ConnectTabTrigger value=".env" />
+ <ConnectTabTrigger value="utils/supabase.ts" />
+ <ConnectTabTrigger value="App.tsx" />
+ </ConnectTabTriggers>
+
+ <ConnectTabContent value=".env">
+ <SimpleCodeBlock className="bash" parentClassName="min-h-72">
+ {`
+VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
+VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
+ `}
+ </SimpleCodeBlock>
+ </ConnectTabContent>
+
+ <ConnectTabContent value="utils/supabase.ts">
+ <SimpleCodeBlock className="ts" parentClassName="min-h-72">
+ {`
+import { createClient } from '@supabase/supabase-js';
+
+const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
+const supabaseKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
+const supabase = createClient(supabaseUrl, supabaseKey);
+
+export default supabase
+ `}
+ </SimpleCodeBlock>
+ </ConnectTabContent>
+
+ <ConnectTabContent value="App.tsx">
+ <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
+ {`
+import { useState, useEffect } from 'react'
+import { supabase } from '../utils/supabase'
+
+function Page() {
+ const [todos, setTodos] = useState([])
+
+ useEffect(() => {
+ function getTodos() {
+ const { data: todos } = await supabase.from('todos').select()
+
+ if (todos.length > 1) {
+ setTodos(todos)
+ }
+ }
+
+ getTodos()
+ }, [])
+
+ return (
+ <div>
+ {todos.map((todo) => (
+ <li key={todo}>{todo}</li>
+ ))}
+ </div>
+ )
+}
+export default Page
+`}
+ </SimpleCodeBlock>
+ </ConnectTabContent>
+ </ConnectTabs>
+ )
+}
+
+export default ContentFile
diff --git a/apps/studio/public/img/libraries/vite-icon.svg b/apps/studio/public/img/libraries/vite-icon.svg
new file mode 100644
index 00000000000..fdee69dbe83
--- /dev/null
+++ b/apps/studio/public/img/libraries/vite-icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="410" height="404" fill="none" viewBox="0 0 410 404"><path fill="url(#a)" d="m399.641 59.525-183.998 329.02c-3.799 6.793-13.559 6.833-17.415.073L10.582 59.556C6.38 52.19 12.68 43.266 21.028 44.76l184.195 32.923c1.175.21 2.378.208 3.553-.006l180.343-32.87c8.32-1.517 14.649 7.337 10.522 14.719Z"/><path fill="url(#b)" d="M292.965 1.574 156.801 28.255a5 5 0 0 0-4.03 4.611l-8.376 141.464c-.197 3.332 2.863 5.918 6.115 5.168l37.91-8.749c3.547-.818 6.752 2.306 6.023 5.873l-11.263 55.153c-.758 3.712 2.727 6.886 6.352 5.785l23.415-7.114c3.63-1.102 7.118 2.081 6.35 5.796l-17.899 86.633c-1.12 5.419 6.088 8.374 9.094 3.728l2.008-3.103 110.954-221.428c1.858-3.707-1.346-7.935-5.418-7.15l-39.022 7.532c-3.667.707-6.787-2.708-5.752-6.296l25.469-88.291c1.036-3.594-2.095-7.012-5.766-6.293Z"/><defs><linearGradient id="a" x1="6" x2="235" y1="33" y2="344" gradientUnits="userSpaceOnUse"><stop stop-color="#41D1FF"/><stop offset="1" stop-color="#BD34FE"/></linearGradient><linearGradient id="b" x1="194.651" x2="236.076" y1="8.818" y2="292.989" gradientUnits="userSpaceOnUse"><stop stop-color="#FFEA83"/><stop offset=".083" stop-color="#FFDD35"/><stop offset="1" stop-color="#FFA800"/></linearGradient></defs></svg>
\ No newline at end of file