mirror of
https://github.com/supabase/supabase.git
synced 2026-07-25 00:42:58 -04:00
192a736d7f
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary - **Documentation** - Reworked API settings content to recommend client libraries for auto-generated Data API endpoints, refreshed authentication/URL guidance, and streamlined API keys messaging. - Updated shared setup partials and restructured the database quickstart with clearer dashboard/management API steps and expanded SQL/RLS snippets. - Updated multiple framework quickstarts to use consistent section-based layouts and refreshed environment-variable instructions across guides. - **Chores** - Expanded MDX heading-case lint allowlist for common framework names (Astro, Flask, Node, Rails, TanStack Start). <!-- end of auto-generated comment: release notes by coderabbit.ai --> ## How to test Run the docs site locally: ```bash pnpm install pnpm dev:docs # serves on http://localhost:3001 ``` Then start with the **Next.js quickstart**, which exercises every change in this PR: 👉 http://localhost:3001/docs/guides/getting-started/quickstarts/nextjs Verify on that page: - [ ] **"Get API details"** section now renders **before** the "Declare environment variables" step, and shows the live **Project URL** + **publishable key** helper widgets (moved into the shared `api_settings.mdx` partial). - [ ] The shadcn/ui **"Explore Components"** CTA appears in the **"Query data"** section (not up top in the create-app step). - [ ] The API keys deprecation notice still renders, and there are no broken/empty partial includes. ### Where to find the rest All other framework quickstarts got the same treatment and live in the same folder — just swap the framework slug in the URL: `http://localhost:3001/docs/guides/getting-started/quickstarts/<framework>` `reactjs`, `vue`, `nuxtjs`, `astrojs`, `tanstack`, `solidjs`, `sveltekit`, `expo-react-native`, `flutter`, `kotlin`, `ios-swiftui`, `flask`, `hono`, `refine`, `redwoodjs`, `ruby-on-rails` Things that vary by framework (worth a quick spot-check across a couple): - **UI CTA** kept only on React-DOM frameworks (Next.js, React, TanStack, Astro); removed from non-React / React Native (Vue, Nuxt, SolidJS, SvelteKit, Expo). - **Mobile guides** (Flutter, Kotlin, iOS SwiftUI): the "Get API details" partial renders *after* the client-init code block, so the key helper widgets show below the snippet rather than beside it. - **Redwood, Hono, Refine, Laravel** Are quite different from the other quickstarts, so I didn't touch them as much and they need some further thought. Because the edited `api_settings.mdx` partial is shared, these non-quickstart pages also render it and are worth a glance: - Auth quickstarts: `/docs/guides/auth/quickstarts/{nextjs,react,react-native,astrojs}` - `/docs/guides/auth/server-side/creating-a-client` - `/docs/guides/realtime/getting_started` - Getting-started setup guides that pull in `project_setup.mdx` / `kotlin_project_setup.mdx` --------- Co-authored-by: awaseem <8704380+awaseem@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Miranda Limonczenko <miranda.limonczenko@supabase.io> Co-authored-by: Jeremias Menichelli <jmenichelli@gmail.com>
137 lines
3.6 KiB
Plaintext
137 lines
3.6 KiB
Plaintext
---
|
|
title: 'Use Supabase Auth with React'
|
|
subtitle: 'Learn how to use Supabase Auth with React.js.'
|
|
breadcrumb: 'Auth Quickstarts'
|
|
hideToc: true
|
|
---
|
|
|
|
<StepHikeCompact>
|
|
|
|
<StepHikeCompact.Step step={1}>
|
|
<StepHikeCompact.Details title="Create a new Supabase project">
|
|
|
|
[Launch a new project](/dashboard) in the Supabase Dashboard.
|
|
|
|
Your new database has a table for storing your users. You can see that this table is currently empty by running some SQL in the [SQL Editor](/dashboard/project/_/sql).
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```sql name=SQL_EDITOR
|
|
select * from auth.users;
|
|
````
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
|
|
<StepHikeCompact.Step step={2}>
|
|
|
|
<StepHikeCompact.Details title="Create a React app">
|
|
|
|
Create a React app using a [Vite](https://vitejs.dev/guide/) template.
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```bash name=Terminal
|
|
npm create vite@latest my-app -- --template react
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
|
|
<StepHikeCompact.Step step={3}>
|
|
<StepHikeCompact.Details title="Install the Supabase client library">
|
|
|
|
Navigate to the React app and install the Supabase libraries.
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```bash name=Terminal
|
|
cd my-app && npm install @supabase/supabase-js
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
<StepHikeCompact.Step step={4}>
|
|
<StepHikeCompact.Details title="Declare Supabase Environment Variables">
|
|
|
|
Rename `.env.example` to `.env.local` and populate with your Supabase connection variables:
|
|
|
|
<$Partial path="api_settings.mdx" variables={{ "framework": "react", "tab": "frameworks" }} />
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
<$CodeSample
|
|
path="/auth/quickstarts/react/.env.example"
|
|
lines={[[1, -1]]}
|
|
meta="name=.env.local"
|
|
/>
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
<StepHikeCompact.Step step={5}>
|
|
<StepHikeCompact.Details title="Set up your login component">
|
|
|
|
<$Partial path="uiLibCta.mdx" />
|
|
|
|
In `App.jsx`, create a Supabase client using your Project URL and key.
|
|
|
|
The code uses the [`getClaims`](/docs/reference/javascript/auth-getclaims) method in `App.jsx` to validate the local JWT before showing the signed-in user.
|
|
|
|
</StepHikeCompact.Details>
|
|
<StepHikeCompact.Code>
|
|
|
|
<$CodeSample
|
|
path="/auth/quickstarts/react/src/App.jsx"
|
|
lines={[[1, -1]]}
|
|
meta="name=src/App.jsx"
|
|
/>
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
|
|
<StepHikeCompact.Step step={6}>
|
|
<StepHikeCompact.Details title="Customize email template">
|
|
|
|
Before proceeding, change the email template to support a server-side authentication flow that sends a token hash:
|
|
|
|
- Go to the [Auth templates](/dashboard/project/_/auth/templates) page in your dashboard.
|
|
- Select the Confirm sign up template.
|
|
- Change `{{ .ConfirmationURL }}` to `{{ .SiteURL }}?token_hash={{ .TokenHash }}&type=email`.
|
|
- Change your [Site URL](/dashboard/project/_/auth/url-configuration) to `https://localhost:5173`
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
</StepHikeCompact.Step>
|
|
|
|
<StepHikeCompact.Step step={7}>
|
|
<StepHikeCompact.Details title="Start the app">
|
|
|
|
Start the app, go to http://localhost:5173 in a browser, and open the browser console and you should be able to register and log in.
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```bash name=Terminal
|
|
npm run dev
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
|
|
</StepHikeCompact>
|