Files
0ae4f32ad9 docs: kaizen fixes to QuickStarts (#47481)
https://github.com/user-attachments/assets/fba86c42-a122-4eb5-8531-db663d022100


Makes a few style and content changes focused on our quickstarts,
starting with
- docs/guides/getting-started/quickstarts/reactjs 
- docs/guides/getting-started/quickstarts/nextjs.

Changes
- Reduced container size and increased x padding for more breathing room
- Adjusted header padding and spacing
- Stripped non critical content from guides
- Merged steps where possible e.g. one sql blocks to run instead of
multiple
- Moved shadcn/supabase ui components into a next step
- Introduced a step for installing agent skills (in future can be
plugin)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Updated multiple quickstarts to add an **“Open Connect panel”**
primary action for environment-variable setup.
  * Removed extra UI CTA partials from several “Query” sections.
* Added **Next steps** links to drop-in UI components and extended the
database flow with an optional **agent skills** step.

* **UI / Guide Layout**
* Refreshed guide spacing/typography (breadcrumb spacing, header
margins, and removed subtitle divider).
* Adjusted guide/table-of-contents sizing and tightened step/details and
code section alignment.
  * Updated main layout width and padding for docs pages.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Chris Chinchilla <chris.ward@supabase.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-07-07 08:38:06 +00:00

101 lines
2.7 KiB
Plaintext

---
title: 'Use Supabase with React'
subtitle: 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a React app.'
breadcrumb: 'Framework Quickstarts'
---
<$Partial path="quickstart_db_setup.mdx" />
## 4. Create a React app
Create a React app using a [Vite](https://vitejs.dev/guide/) template.
```bash
npm create vite@latest my-app -- --template react
```
## 5. Install the Supabase client library
The fastest way to get started is to use the `supabase-js` client library, which provides a convenient interface for working with Supabase from a React app.
Navigate to the React app and install `supabase-js`.
```bash
cd my-app && npm install @supabase/supabase-js
```
<$Partial path="api_settings.mdx" variables={{ "framework": "react", "tab": "frameworks" }} />
## 6. Declare Supabase environment variables
Create a `.env.local` file and populate it with your Supabase URL and publishable key that you can get from the helper above, or [from the project **Connect** panel](/dashboard/project/_?showConnect=true&framework=react&tab=frameworks)
<Button variant="primary" asChild>
<a href="/dashboard/project/_?showConnect=true&connectTab=frameworks&framework=react">
Open Connect panel
</a>
</Button>
```text name=.env.local
VITE_SUPABASE_URL=<SUBSTITUTE_SUPABASE_URL>
VITE_SUPABASE_PUBLISHABLE_KEY=<SUBSTITUTE_SUPABASE_PUBLISHABLE_KEY>
```
## 7. Query data from the app
Replace the contents of `App.jsx` with a `getInstruments` function that fetches the data and displays the query result on the page using a Supabase client.
```js name=src/App.jsx
import { createClient } from '@supabase/supabase-js'
import { useEffect, useState } from 'react'
const supabase = createClient(
import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY
)
function App() {
const [instruments, setInstruments] = useState([])
useEffect(() => {
getInstruments()
}, [])
async function getInstruments() {
const { data, error } = await supabase.from('instruments').select()
if (error) {
console.error(error)
return
}
setInstruments(data)
}
return (
<ul>
{instruments.map((instrument) => (
<li key={instrument.name}>{instrument.name}</li>
))}
</ul>
)
}
export default App
```
## 8. Start the app
Run the development server, go to http://localhost:5173 in a browser, and you should see the list of instruments.
```bash
npm run dev
```
## Next steps
- Explore [drop-in UI components](/ui) for your Supabase app
- Set up [Auth](/docs/guides/auth) for your app
- [Insert more data](/docs/guides/database/import-data) into your database
- Upload and serve static files using [Storage](/docs/guides/storage)