mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Docs update. Getting Started page is the most visited page in the docs at the moment: https://supabase.com/docs/guides/getting-started. Looking at all 19 guides, they appear to have drifted apart because there was never a written standard for what a quickstart must contain. Additionally, we are missing some frameworks, languages, and ORMs quickstarts. Phase 1 (this PR) fixes broken numbering, duplicated steps, and dead-end pages. Later phases bring all 19 guides into line with a single "definition of done" contract (error handling in samples, env vars everywhere, consistent Connect-panel pattern). The end goal is that every quickstart, regardless of framework, gives the same complete, trustworthy path from zero to a working app. ## What is the new behavior? 1. SvelteKit and Hono cards added to the [homepage grid](https://docs-git-docs-fix-quickstart-catalog-gaps-supabase.vercel.app/docs) (FrameworkQuickstarts.tsx). Only added the most popular missing frameworks to the grid. 2. [Rails](https://docs-git-docs-fix-quickstart-catalog-gaps-supabase.vercel.app/docs/guides/getting-started/quickstarts/ruby-on-rails#2-install-agent-skills-optional): Add missing second step (Agent Skills), add next steps at the end (point 6) 3. [Laravel](https://docs-git-docs-fix-quickstart-catalog-gaps-supabase.vercel.app/docs/guides/getting-started/quickstarts/laravel#6-set-up-the-postgres-connection-details): Remove duplicated instruction to create project from step 6. 4. [Refine](https://docs-git-docs-fix-quickstart-catalog-gaps-supabase.vercel.app/docs/guides/getting-started/quickstarts/refine#5-update-supabaseclient-with-environment-variables): In step 5, create .env file (VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY), and the client reads them via import.meta.env, matching the Vite-based refine-supabase preset. 5. [Hono](https://docs-git-docs-fix-quickstart-catalog-gaps-supabase.vercel.app/docs/guides/getting-started/quickstarts/hono#6-set-up-the-required-environment-variables) TODO resolved: In step 6, add the "Open Connect panel" Button with the generic api_settings.mdx partial call, identical to the Flask and Expo pattern. 6. Next steps added to the 9 guides missing it at the end of the guide, linking to the framework tutorial or Auth, UI components, data import, and Storage (Flutter, Kotlin, Laravel, Nuxt, RedwoodJS, Refine, Ruby on Rails, SolidJS, and Vue). 7. Remove 4 stale screenshots from RedwoodJS and Refine, along with their now-orphaned image assets under apps/docs/public/img/. The surrounding text already covers what they showed; they weren't Connect-panel screens, so the Button pattern didn't apply as a replacement. 8. Add [Supabase Agent Skills](https://docs-git-docs-fix-quickstart-catalog-gaps-supabase.vercel.app/docs/guides/getting-started/quickstarts/nextjs#4-install-agent-skills-optional) purpose and benefits for the user 9. Start all guides from creating Supabase project ## Additional context Add any other context or screenshots. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Documentation - Added SvelteKit and Hono quickstarts with icons and documentation links. - Expanded Agent Skills guidance across framework quickstarts, including current authentication, SSR, and migration patterns. - Improved project creation, Connect panel, API configuration, and credential setup instructions. - Added framework-specific “Next steps” resources for Auth, database imports, Storage, UI components, and libraries. - Clarified PostgreSQL SSL, password encoding, connection, and environment-variable requirements. - Replaced outdated screenshots with clearer setup guidance and relevant examples. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
146 lines
4.8 KiB
Plaintext
146 lines
4.8 KiB
Plaintext
---
|
|
title: 'Use Supabase with TanStack Start'
|
|
subtitle: 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a TanStack Start app.'
|
|
breadcrumb: 'Framework Quickstarts'
|
|
---
|
|
|
|
<AiPrompt id="tanstack" />
|
|
|
|
<$Partial path="quickstart_db_setup.mdx" />
|
|
|
|
## 3. Create a TanStack Start app
|
|
|
|
Create a TanStack Start app using the official CLI.
|
|
|
|
```bash
|
|
npx @tanstack/cli@latest create my-app
|
|
```
|
|
|
|
## 4. Install Supabase's Agent Skills (optional)
|
|
|
|
Supabase's [Agent Skills](/docs/guides/ai-tools/ai-skills) is a curated set of instructions that give your AI agent procedural knowledge about working with Supabase.
|
|
|
|
Install them so your AI coding agent can produce more accurate, reliable code using current Supabase patterns, such as authentication, server-side rendering, and database migrations, rather than relying solely on training data.
|
|
|
|
To install, run the following command in the root of your project:
|
|
|
|
```bash
|
|
npx skills add supabase/agent-skills
|
|
```
|
|
|
|
## 5. Install the Supabase client libraries
|
|
|
|
Navigate to the TanStack Start app and install `supabase-js` and `@supabase/ssr`, the helper package that manages cookie-based sessions for server-side rendering.
|
|
|
|
```bash
|
|
cd my-app && npm install @supabase/supabase-js @supabase/ssr
|
|
```
|
|
|
|
## 6. Declare Supabase environment variables
|
|
|
|
Create a `.env.local` file in the root of your project and populate it with your Supabase connection variables. Get the values from the helper below, or [from the project **Connect** panel](/dashboard/project/_?showConnect=true&connectTab=frameworks&framework=tanstack).
|
|
|
|
<Button variant="primary" asChild>
|
|
<a href="/dashboard/project/_?showConnect=true&connectTab=frameworks&framework=tanstack">
|
|
Open Connect panel
|
|
</a>
|
|
</Button>
|
|
|
|
```text name=.env.local
|
|
VITE_SUPABASE_URL=<SUBSTITUTE_SUPABASE_URL>
|
|
VITE_SUPABASE_PUBLISHABLE_KEY=<SUBSTITUTE_SUPABASE_PUBLISHABLE_KEY>
|
|
```
|
|
|
|
<$Partial path="api_settings.mdx" variables={{ "framework": "tanstack", "tab": "frameworks" }} />
|
|
|
|
## 7. Create Supabase client utilities
|
|
|
|
TanStack Start needs two Supabase clients: a browser client for components that run in the browser, and a server client for loaders and server functions. Create a `src/lib/supabase` folder with a file for each client.
|
|
|
|
```ts name=src/lib/supabase/client.ts
|
|
/// <reference types="vite/types/importMeta.d.ts" />
|
|
import { createBrowserClient } from '@supabase/ssr'
|
|
|
|
export function createClient() {
|
|
return createBrowserClient(
|
|
import.meta.env.VITE_SUPABASE_URL!,
|
|
import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY!
|
|
)
|
|
}
|
|
```
|
|
|
|
```ts name=src/lib/supabase/server.ts
|
|
import { createServerClient } from '@supabase/ssr'
|
|
import { getCookies, setCookie, setResponseHeader } from '@tanstack/react-start/server'
|
|
|
|
export function createClient() {
|
|
return createServerClient(
|
|
process.env.VITE_SUPABASE_URL!,
|
|
process.env.VITE_SUPABASE_PUBLISHABLE_KEY!,
|
|
{
|
|
cookies: {
|
|
getAll() {
|
|
return Object.entries(getCookies()).map(([name, value]) => ({ name, value }))
|
|
},
|
|
setAll(cookies, headers) {
|
|
cookies.forEach(({ name, value, options }) => {
|
|
setCookie(name, value, options)
|
|
})
|
|
|
|
Object.entries(headers).forEach(([name, value]) => {
|
|
setResponseHeader(name, value)
|
|
})
|
|
},
|
|
},
|
|
}
|
|
)
|
|
}
|
|
```
|
|
|
|
## 8. Query Supabase data from TanStack Start
|
|
|
|
Replace the contents of `src/routes/index.tsx` with the following to add a loader that queries the `instruments` table through the server client. The loader runs on the server, so the data is part of the initial server-rendered response.
|
|
|
|
```tsx name=src/routes/index.tsx
|
|
import { createFileRoute } from '@tanstack/react-router'
|
|
|
|
import { createClient } from '@/lib/supabase/server'
|
|
|
|
export const Route = createFileRoute('/')({
|
|
loader: async () => {
|
|
const supabase = createClient()
|
|
const { data: instruments } = await supabase.from('instruments').select()
|
|
return { instruments }
|
|
},
|
|
component: Home,
|
|
})
|
|
|
|
function Home() {
|
|
const { instruments } = Route.useLoaderData()
|
|
|
|
return (
|
|
<ul>
|
|
{instruments?.map((instrument) => (
|
|
<li key={instrument.name}>{instrument.name}</li>
|
|
))}
|
|
</ul>
|
|
)
|
|
}
|
|
```
|
|
|
|
## 9. Start the app
|
|
|
|
Run the development server, go to http://localhost:3000 in a browser and you should see the list of instruments.
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
## Next steps
|
|
|
|
- Learn how to [protect routes and check sessions](/docs/guides/auth/server-side/creating-a-client?queryGroups=framework&framework=tanstack) with the server client
|
|
- Set up a complete [login and sign-up flow](/ui/docs/tanstack/password-based-auth) from the Supabase UI Library
|
|
- Explore [drop-in UI components](/ui) for your Supabase app
|
|
- [Insert more data](/docs/guides/database/import-data) into your database
|
|
- Upload and serve static files using [Storage](/docs/guides/storage)
|