Skip to content

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

docs: add agent prompts to all 18 framework quickstarts (#47543)

Nik Richersd46cc88f099d
diff --git a/apps/docs/content/guides/getting-started/quickstarts/astrojs.mdx b/apps/docs/content/guides/getting-started/quickstarts/astrojs.mdx
index 392227c9fb6..34167ca1d6e 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/astrojs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/astrojs.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add sample data, and query fr
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="astrojs" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create an Astro app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/expo-react-native.mdx b/apps/docs/content/guides/getting-started/quickstarts/expo-react-native.mdx
index d9b581b5e9f..ec1988bc43c 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/expo-react-native.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/expo-react-native.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="expo-react-native" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create an Expo app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/flask.mdx b/apps/docs/content/guides/getting-started/quickstarts/flask.mdx
index aa3be961447..72b6594f860 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/flask.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/flask.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="flask" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Python app with Flask
diff --git a/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx b/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx
index c34cef02b6a..ec829974b57 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="flutter" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Flutter app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/hono.mdx b/apps/docs/content/guides/getting-started/quickstarts/hono.mdx
index 6d9c331172c..8168753a9da 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/hono.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/hono.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="hono" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Hono app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx b/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx
index 24523e7027e..6d0c15d2f74 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="ios-swiftui" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create an iOS SwiftUI app with Xcode
diff --git a/apps/docs/content/guides/getting-started/quickstarts/kotlin.mdx b/apps/docs/content/guides/getting-started/quickstarts/kotlin.mdx
index 6c9b2d1fa71..eaf76bc137a 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/kotlin.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/kotlin.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="kotlin" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create an Android app with Android Studio
diff --git a/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx b/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx
index 6c9e55acc60..ff1b4695f41 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a PHP Laravel project, connect it to your Supabas
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="laravel" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Laravel project
diff --git a/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx
index 654823cecf8..6b3f254677a 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data, and que
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="nextjs" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Next.js app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx
index c91850e0df3..542b7b4976c 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="nuxtjs" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Nuxt app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx
index 515e6267c68..cfd88622d2f 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="reactjs" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a React app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx
index 4bd411ef331..2583f048ef1 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="redwoodjs" />
+
## 1. Setup your new Supabase project
[Create a new project](/dashboard) in the Supabase Dashboard.
diff --git a/apps/docs/content/guides/getting-started/quickstarts/refine.mdx b/apps/docs/content/guides/getting-started/quickstarts/refine.mdx
index 5fe26f5057a..a3a3389d5e1 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/refine.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/refine.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="refine" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Refine app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx b/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx
index f1d6a8aef66..b513a76961a 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Rails project and connect it to your Supabase P
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="ruby-on-rails" />
+
## 1. Create a Rails project
With your Ruby and Rails versions up to date, run `rails new` on your terminal to scaffold a new project.
diff --git a/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx
index 6ac87800239..bbab847700b 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="solidjs" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a SolidJS app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx b/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx
index 669079174bc..90877e33d9f 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="sveltekit" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a SvelteKit app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/tanstack.mdx b/apps/docs/content/guides/getting-started/quickstarts/tanstack.mdx
index 3fe6ac2a5da..885b6dffa64 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/tanstack.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/tanstack.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="tanstack" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a TanStack Start app
diff --git a/apps/docs/content/guides/getting-started/quickstarts/vue.mdx b/apps/docs/content/guides/getting-started/quickstarts/vue.mdx
index 6e34ba1244e..5b533e85179 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/vue.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/vue.mdx
@@ -4,6 +4,8 @@ subtitle: 'Learn how to create a Supabase project, add some sample data to your
breadcrumb: 'Framework Quickstarts'
---
+<AiPrompt id="vue" />
+
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Vue app
diff --git a/apps/docs/data/ai-prompts.data.ts b/apps/docs/data/ai-prompts.data.ts
new file mode 100644
index 00000000000..74cf6930033
--- /dev/null
+++ b/apps/docs/data/ai-prompts.data.ts
@@ -0,0 +1,246 @@
+/** Embedded AI prompt bodies keyed by `AiPrompt` `id`. */
+export const aiPrompts = {
+ astrojs: `Help me add Supabase to my Astro project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npm create astro@latest my-app\` to scaffold the app.
+2. Run \`npm install @supabase/supabase-js @astrojs/node\`.
+3. Update \`astro.config.mjs\` to enable SSR with the Node adapter.
+4. Create \`.env.local\` and set \`PUBLIC_SUPABASE_URL\` and
+ \`PUBLIC_SUPABASE_PUBLISHABLE_KEY\`.
+5. Create \`src/lib/supabase.ts\` with a \`createServerClient()\` helper function.
+6. Create \`src/pages/instruments.astro\` to query and display the instruments
+ table.
+7. Run \`npm run dev\` and open http://localhost:4321/instruments.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/astrojs.md`,
+ 'expo-react-native': `Help me add Supabase to my Expo React Native project. Create a Supabase project
+at database.new and run the instruments table SQL. Then:
+1. Run \`npx create-expo-app my-app --template blank-typescript\` to scaffold the
+ app.
+2. Run \`npx expo install @supabase/supabase-js react-native-url-polyfill
+ expo-sqlite\` to install dependencies.
+3. Create \`.env\` and set \`EXPO_PUBLIC_SUPABASE_URL\` and
+ \`EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY\`.
+4. Create \`lib/supabase.ts\` to initialize the Supabase client with localStorage
+ persistence.
+5. Update \`App.tsx\` to fetch and display instruments using \`useEffect\` and
+ \`FlatList\`.
+6. Run \`npx expo start\` and scan the QR code or press \`i\`/\`a\` for simulator.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/expo-react-native.md`,
+ flask: `Help me add Supabase to my Python Flask project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Create a project directory and activate a virtual environment with
+ \`python3 -m venv venv && source venv/bin/activate\`.
+2. Install dependencies with \`pip install flask supabase\`.
+3. Create \`.env\` and set \`SUPABASE_URL\` and \`SUPABASE_PUBLISHABLE_KEY\`.
+4. Install \`python-dotenv\` and create \`app.py\` with a Flask route that queries
+ and renders the instruments table using the Supabase client.
+5. Run \`python app.py\` and open http://localhost:5000.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/flask.md`,
+ flutter: `Help me add Supabase to my Flutter project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`flutter create my_app\` to scaffold the app.
+2. Add \`supabase_flutter: ^2.0.0\` to \`pubspec.yaml\`.
+3. Initialize Supabase in \`lib/main.dart\` with your project URL and publishable
+ key.
+4. Replace the default app with a \`FutureBuilder\` and \`ListView\` to query and
+ display the instruments table.
+5. Run \`flutter run\` to start the app.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/flutter.md`,
+ hono: `Help me add Supabase to my Hono project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npx supabase@latest bootstrap hono\` to scaffold the app with Supabase
+ and SSR auth pre-configured.
+2. Run \`npm install\` to install dependencies.
+3. Copy \`.env.example\` to \`.env\`, set your Supabase URL and publishable key,
+ and enable anonymous sign-ins in the Auth settings.
+4. Run \`npm run dev\` and open http://localhost:5173.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/hono.md`,
+ 'ios-swiftui': `Help me add Supabase to my iOS SwiftUI project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Create a new iOS App project in Xcode.
+2. Add the \`supabase-swift\` package via File > Add Package Dependencies using
+ the GitHub URL https://github.com/supabase/supabase-swift.
+3. Create \`Supabase.swift\` and initialize \`SupabaseClient\` with your project
+ URL and publishable key.
+4. Create \`Instrument.swift\` as a decodable struct.
+5. Update \`ContentView.swift\` to fetch and display the instruments table using
+ a \`task\` modifier and \`List\`.
+6. Run the app with Cmd + R in Xcode.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/ios-swiftui.md`,
+ kotlin: `Help me add Supabase to my Android Kotlin project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Create a new Android project in Android Studio.
+2. Add the Kotlin serialization plugin, Ktor client, and Supabase BOM to
+ \`build.gradle.kts\`.
+3. Add \`<uses-permission android:name="android.permission.INTERNET" />\` to
+ \`AndroidManifest.xml\`.
+4. Initialize the Supabase client in \`MainActivity.kt\` with your project URL
+ and publishable key.
+5. Add a serializable \`Instrument\` data class.
+6. Use \`LaunchedEffect\` and \`LazyColumn\` to fetch and display the instruments
+ table.
+7. Click Run in Android Studio to start the app.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/kotlin.md`,
+ laravel: `Help me add Supabase to my Laravel project. Create a Supabase project at
+database.new. Then:
+1. Run \`composer create-project laravel/laravel example-app\` to scaffold the
+ project.
+2. Install Laravel Breeze with \`composer require laravel/breeze --dev &&
+ php artisan breeze:install\`.
+3. Copy the Session Pooler connection string from the Supabase Connect panel
+ and set \`DB_URL\` in \`.env\`.
+4. Set \`search_path\` to a custom schema (e.g. \`laravel\`) in
+ \`config/database.php\`.
+5. Run \`php artisan migrate\` to apply database migrations.
+6. Run \`php artisan serve\` and open http://127.0.0.1:8000.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/laravel.md`,
+ nextjs: `Help me add Supabase to my Next.js project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npx create-next-app -e with-supabase\` to scaffold the app.
+2. Rename \`.env.example\` to \`.env.local\` and set \`NEXT_PUBLIC_SUPABASE_URL\` and
+ \`NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY\`.
+3. Create \`app/instruments/page.tsx\` using \`createClient()\` from
+ \`@/lib/supabase/server\` to query and display the instruments table.
+4. Run \`npm run dev\` and open http://localhost:3000/instruments.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/nextjs.md`,
+ nuxtjs: `Help me add Supabase to my Nuxt project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npx nuxi@latest init my-app\` to scaffold the app.
+2. Run \`npm install @supabase/supabase-js\`.
+3. Create \`.env\` with \`SUPABASE_URL\` and \`SUPABASE_PUBLISHABLE_KEY\` and expose
+ them via \`nuxt.config.ts\` runtimeConfig.
+4. Update \`app.vue\` to create a Supabase client and fetch and display the
+ instruments table on mount.
+5. Run \`npm run dev\` and open http://localhost:3000.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/nuxtjs.md`,
+ reactjs: `Help me add Supabase to my React project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npm create vite@latest my-app -- --template react\` to scaffold the
+ app.
+2. Run \`npm install @supabase/supabase-js\`.
+3. Create \`.env.local\` and set \`VITE_SUPABASE_URL\` and
+ \`VITE_SUPABASE_PUBLISHABLE_KEY\`.
+4. Update \`src/App.jsx\` to create a Supabase client and fetch and display the
+ instruments table using \`useEffect\`.
+5. Run \`npm run dev\` and open http://localhost:5173.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/reactjs.md`,
+ redwoodjs: `Help me add Supabase to my RedwoodJS project. Create a Supabase project at
+database.new and copy the Transaction and Session pooler connection strings.
+Then:
+1. Run \`yarn create redwood-app my-app --ts\` to scaffold the app.
+2. Set \`DATABASE_URL\` (Transaction pooler with \`?pgbouncer=true\`) and
+ \`DIRECT_URL\` (Session pooler) in \`.env\`.
+3. Update \`api/db/schema.prisma\` to use the PostgreSQL datasource with those
+ env vars.
+4. Add an \`Instrument\` model to the Prisma schema and run \`yarn rw prisma
+ migrate dev\`.
+5. Update \`scripts/seed.ts\` with instrument data and run \`yarn rw prisma db
+ seed\`.
+6. Run \`yarn rw g scaffold instrument\` to scaffold the CRUD UI.
+7. Run \`yarn rw dev\` and open http://localhost:8910/instruments.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/redwoodjs.md`,
+ refine: `Help me add Supabase to my Refine project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npm create refine-app@latest -- --preset refine-supabase my-app\` to
+ scaffold the app with Supabase pre-configured.
+2. Update \`src/utility/supabaseClient.ts\` with your Supabase URL and publishable
+ key.
+3. Run \`npm run refine create-resource instruments\` to generate CRUD pages for
+ the instruments table.
+4. Update \`src/App.tsx\` to add routes for the instruments list, create, edit,
+ and show pages.
+5. Run \`npm run dev\` and open http://localhost:5173/instruments.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/refine.md`,
+ 'ruby-on-rails': `Help me add Supabase to my Ruby on Rails project. Create a Supabase project at
+database.new. Then:
+1. Run \`rails new blog -d=postgresql\` to scaffold a new Rails project.
+2. Set \`DATABASE_URL\` to the Supabase Session Pooler connection string in
+ \`.env\`.
+3. Generate an Article model with \`bin/rails generate model Article
+ title:string body:text\` and run \`bin/rails db:migrate\`.
+4. Use \`bin/rails console\` to create and query articles.
+5. Run \`bin/rails server\` and open http://127.0.0.1:3000.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/ruby-on-rails.md`,
+ solidjs: `Help me add Supabase to my SolidJS project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npx degit solidjs/templates/js my-app\` to scaffold the app.
+2. Run \`npm install @supabase/supabase-js\`.
+3. Create \`.env.local\` and set \`VITE_SUPABASE_URL\` and
+ \`VITE_SUPABASE_PUBLISHABLE_KEY\`.
+4. Update \`src/App.jsx\` to create a Supabase client and fetch and display the
+ instruments table using \`createResource\`.
+5. Run \`npm run dev\` and open http://localhost:3000.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/solidjs.md`,
+ sveltekit: `Help me add Supabase to my SvelteKit project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npx sv create my-app\` to scaffold the app.
+2. Run \`npm install @supabase/supabase-js\`.
+3. Create \`.env\` and set \`PUBLIC_SUPABASE_URL\` and
+ \`PUBLIC_SUPABASE_PUBLISHABLE_KEY\`.
+4. Create \`src/lib/supabaseClient.js\` to initialize the Supabase client.
+5. Create \`src/routes/+page.server.js\` with a \`load\` function that fetches and
+ returns the instruments table.
+6. Run \`npm run dev\` and open http://localhost:5173.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/sveltekit.md`,
+ tanstack: `Help me add Supabase to my TanStack Start project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npx @tanstack/cli@latest create my-app\` to scaffold the app.
+2. Run \`npm install @supabase/supabase-js @supabase/ssr\`.
+3. Create \`.env.local\` and set \`VITE_SUPABASE_URL\` and
+ \`VITE_SUPABASE_PUBLISHABLE_KEY\`.
+4. Create \`src/lib/supabase/client.ts\` and \`src/lib/supabase/server.ts\` for
+ browser and server clients.
+5. Update \`src/routes/index.tsx\` with a loader that queries and displays the
+ instruments table using the server client.
+6. Run \`npm run dev\` and open http://localhost:3000.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/tanstack.md`,
+ vue: `Help me add Supabase to my Vue project. Create a Supabase project at
+database.new and run the instruments table SQL. Then:
+1. Run \`npm init vue@latest my-app\` to scaffold the app.
+2. Run \`npm install @supabase/supabase-js\`.
+3. Create \`.env.local\` and set \`VITE_SUPABASE_URL\` and
+ \`VITE_SUPABASE_PUBLISHABLE_KEY\`.
+4. Create \`src/lib/supabaseClient.js\` to initialize the Supabase client.
+5. Update \`src/App.vue\` to fetch and display the instruments table using
+ \`onMounted\`.
+6. Run \`npm run dev\` and open http://localhost:5173.
+
+REFERENCE
+https://supabase.com/docs/guides/getting-started/quickstarts/vue.md`,
+} as const
+
+export type AiPromptId = keyof typeof aiPrompts
diff --git a/apps/docs/features/directives/Partial.ts b/apps/docs/features/directives/Partial.ts
index 86001a7ade8..956b8e06b2a 100644
--- a/apps/docs/features/directives/Partial.ts
+++ b/apps/docs/features/directives/Partial.ts
@@ -40,6 +40,7 @@
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import { PARTIALS_DIRECTORY } from '~/lib/docs'
+import { parsePartialVariables, substitutePartialVars } from '~/lib/partials.utils'
import { type Root } from 'mdast'
import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx'
import { type Parent } from 'unist'
@@ -77,40 +78,8 @@ function toFilePath(node: MdxJsxFlowElement) {
return filePath
}
-/**
- * Substitutes provided variables into the partial content. Variable
- * substitution is optional: any variable referenced in the content but not
- * provided is replaced with an empty string, and any variable provided but not
- * referenced is ignored. The leading `\` escape (`\{{ .var }}`) opts a
- * placeholder out of substitution.
- */
-function substituteVars(content: string, vars: Record<string, string> | undefined) {
- for (const [key, value] of Object.entries(vars ?? {})) {
- content = content.replace(new RegExp(`(?<!\\\\)\\{\\{\\s*\\.${key}\\s*\\}\\}`, 'g'), value)
- }
-
- // Clear any remaining (unprovided) placeholders.
- content = content.replace(/(?<!\\)\{\{\s*\.[\w-]+\s*\}\}/g, '')
- return content
-}
-
function getVariables(node: MdxJsxFlowElement): undefined | Record<string, string> {
- const variables = getAttributeValueExpression(getAttributeValue(node, 'variables'))
- if (variables === undefined) {
- return
- }
-
- try {
- const parsed = JSON.parse(variables)
- for (const value of Object.values(parsed)) {
- if (typeof value !== 'string') {
- throw new Error('Only string values are allowed')
- }
- }
- return parsed
- } catch {
- throw new Error('Invalid $Partial variables: must be valid JSON containing only string values')
- }
+ return parsePartialVariables(getAttributeValueExpression(getAttributeValue(node, 'variables')))
}
async function fetchPartialsContent(tree: Root) {
@@ -146,7 +115,7 @@ function rewriteNodes(
contentMap: Map<MdxJsxFlowElement, [Parent, string, undefined | Record<string, string>]>
) {
for (const [node, [parent, rawContent, vars]] of contentMap) {
- const content = substituteVars(rawContent.trim(), vars)
+ const content = substitutePartialVars(rawContent.trim(), vars)
const replacementContent = fromDocsMarkdown(content)
parent.children.splice(parent.children.indexOf(node), 1, replacementContent)
}
diff --git a/apps/docs/features/docs/MdxBase.shared.tsx b/apps/docs/features/docs/MdxBase.shared.tsx
index 6c17ae6b5e5..8d47edbeb13 100644
--- a/apps/docs/features/docs/MdxBase.shared.tsx
+++ b/apps/docs/features/docs/MdxBase.shared.tsx
@@ -41,9 +41,9 @@ import SqlToRest from 'ui-patterns/SqlToRest'
import { Heading } from 'ui/src/components/CustomHTMLElements'
import { AgentPluginsPanel } from '../ui/AgentPluginsPanel'
+import { AiPrompt } from '../ui/AiPrompt'
import { ErrorCodes } from '../ui/ErrorCodes'
import { McpConfigPanel } from '../ui/McpConfigPanel'
-import { Prompt, PromptContent, PromptCopy, PromptPanel, PromptTitle } from '../ui/PromptPanel'
// Wrap Admonition for Docs-specific styling (within MDX prose, requires a margin-bottom)
const AdmonitionWithMargin = (props: AdmonitionProps) => {
@@ -71,6 +71,7 @@ const components = {
AccordionItem,
Admonition: AdmonitionWithMargin,
AgentPluginsPanel,
+ AiPrompt,
AiPromptsIndex,
AiSkillsIndex,
AuthSmsProviderConfig,
@@ -101,11 +102,6 @@ const components = {
NamedCodeBlock,
NavData,
ProjectConfigVariables,
- Prompt,
- PromptContent,
- PromptCopy,
- PromptPanel,
- PromptTitle,
RealtimeLimitsEstimator,
RegionsList,
SmartRegionsList,
diff --git a/apps/docs/features/ui/AiPrompt.tsx b/apps/docs/features/ui/AiPrompt.tsx
new file mode 100644
index 00000000000..0abe0bac1cd
--- /dev/null
+++ b/apps/docs/features/ui/AiPrompt.tsx
@@ -0,0 +1,40 @@
+'use client'
+
+import { aiPrompts, type AiPromptId } from '~/data/ai-prompts.data'
+import { Sparkles } from 'lucide-react'
+
+import { Prompt, PromptContent, PromptCopy, PromptPanel, PromptTitle } from './PromptPanel'
+
+type AiPromptProps = {
+ /** Looks up prompt text from `aiPrompts`. */
+ id: AiPromptId | string
+}
+
+/**
+ * MDX-facing wrapper around {@link PromptPanel}. Composes the compound
+ * children in this client module so detection does not cross the RSC
+ * boundary (where child types arrive as `react.lazy` and the panel
+ * would otherwise render nothing).
+ *
+ * Prompt text lives in `~/data/ai-prompts.data`. Markdown export
+ * intentionally omits this component (HTML-only copy panel).
+ */
+function AiPrompt({ id }: AiPromptProps) {
+ const prompt = aiPrompts[id as AiPromptId]
+ if (!prompt) {
+ throw new Error(`Unknown AiPrompt id: ${id}`)
+ }
+
+ return (
+ <PromptPanel>
+ <Prompt value="prompt" expandable>
+ <PromptTitle icon={<Sparkles />}>AI Prompt</PromptTitle>
+ <PromptCopy>{prompt}</PromptCopy>
+ <PromptContent>{prompt}</PromptContent>
+ </Prompt>
+ </PromptPanel>
+ )
+}
+
+export { AiPrompt }
+export type { AiPromptProps }
diff --git a/apps/docs/features/ui/PromptPanel.tsx b/apps/docs/features/ui/PromptPanel.tsx
index 8155548b703..7cbc87363a4 100644
--- a/apps/docs/features/ui/PromptPanel.tsx
+++ b/apps/docs/features/ui/PromptPanel.tsx
@@ -204,7 +204,11 @@ function CopyButton({ label, value }: { label: string; value: string }) {
function TabLabel({ icon, children }: { icon?: ReactNode; children: ReactNode }) {
return (
<span className="inline-flex items-center gap-1.5">
- {icon && <span className="text-tertiary-foreground [&_svg]:size-3.5">{icon}</span>}
+ {icon && (
+ <span aria-hidden="true" className="text-tertiary-foreground [&_svg]:size-3.5">
+ {icon}
+ </span>
+ )}
{children}
</span>
)
@@ -230,6 +234,7 @@ const tabTriggerClassName = 'h-full px-0 py-0 text-xs shadow-none data-[state=ac
*/
function PromptPanel({ children, className }: PromptPanelProps) {
const fallbackId = useId()
+ const titleId = useId()
const prompts = collectPrompts(children)
const [activeTab, setActiveTab] = useState(prompts[0]?.value ?? fallbackId)
const [shimmerEnabled, setShimmerEnabled] = useState(true)
@@ -252,6 +257,7 @@ function PromptPanel({ children, className }: PromptPanelProps) {
</TabsList>
) : (
<span
+ id={titleId}
className={cn(
'inline-flex items-center justify-center whitespace-nowrap border-b-2 border-transparent text-foreground-lighter',
tabTriggerClassName
@@ -271,6 +277,8 @@ function PromptPanel({ children, className }: PromptPanelProps) {
if (!hasTabs) {
return (
<div
+ role="region"
+ aria-labelledby={titleId}
onFocusCapture={dismissShimmer}
onPointerEnter={dismissShimmer}
className={cn(
diff --git a/apps/docs/internals/generate-guides-markdown.ts b/apps/docs/internals/generate-guides-markdown.ts
index bb87dd02876..662b5c4bf4a 100644
--- a/apps/docs/internals/generate-guides-markdown.ts
+++ b/apps/docs/internals/generate-guides-markdown.ts
@@ -1,5 +1,6 @@
import fs from 'node:fs/promises'
import path from 'node:path'
+import { parsePartialVariables, substitutePartialVars } from '~/lib/partials.utils'
import matter from 'gray-matter'
import type { Content, Parent, Root } from 'mdast'
import { fromMarkdown } from 'mdast-util-from-markdown'
@@ -101,6 +102,17 @@ function propsFrom(node: JsxNode): Props {
return props
}
+function resolvePartialPath(partialPath: string): string {
+ if (!partialPath.endsWith('.md') && !partialPath.endsWith('.mdx')) {
+ throw new Error('Invalid $Partial path: path must end with .mdx or .md')
+ }
+ const resolved = path.join(PARTIALS_DIR, partialPath)
+ if (!resolved.startsWith(PARTIALS_DIR)) {
+ throw new Error(`Invalid $Partial path: path must be inside ${PARTIALS_DIR}`)
+ }
+ return resolved
+}
+
/**
* Replaces every `<$Partial path="..." />` in the tree with the parsed AST of
* the referenced file. Recurses so partials may include other partials.
@@ -109,10 +121,14 @@ async function inlinePartials(parent: Parent): Promise<void> {
const next: Content[] = []
for (const child of parent.children as Content[]) {
if (isJsx(child) && child.name === '$Partial') {
- const partialPath = String(propsFrom(child).path ?? '')
+ const props = propsFrom(child)
+ const partialPath = String(props.path ?? '')
+ const variables = parsePartialVariables(props.variables)
+ const resolvedPath = resolvePartialPath(partialPath)
try {
- const raw = await fs.readFile(path.join(PARTIALS_DIR, partialPath), 'utf8')
- const subtree = parseMdx(matter(raw).content)
+ const raw = await fs.readFile(resolvedPath, 'utf8')
+ const content = substitutePartialVars(matter(raw).content, variables)
+ const subtree = parseMdx(content)
await inlinePartials(subtree)
next.push(...(subtree.children as Content[]))
} catch {
diff --git a/apps/docs/lib/partials.utils.test.ts b/apps/docs/lib/partials.utils.test.ts
new file mode 100644
index 00000000000..4a911fb6c69
--- /dev/null
+++ b/apps/docs/lib/partials.utils.test.ts
@@ -0,0 +1,67 @@
+import { describe, expect, it } from 'vitest'
+
+import { parsePartialVariables, substitutePartialVars } from './partials.utils'
+
+describe('substitutePartialVars', () => {
+ it('substitutes provided variables', () => {
+ const content = 'Here is a partial that takes a {{ .var }}.'
+ expect(substitutePartialVars(content, { var: 'string replacement' })).toBe(
+ 'Here is a partial that takes a string replacement.'
+ )
+ })
+
+ it('renders unprovided variables as empty strings', () => {
+ const content = 'Here is a partial that takes a {{ .var }}.'
+ expect(substitutePartialVars(content, undefined)).toBe('Here is a partial that takes a .')
+ })
+
+ it('ignores variables that are not referenced in the content', () => {
+ const content = 'Here is a partial that takes a {{ .var }}.'
+ expect(substitutePartialVars(content, { var: 'correct', extra: 'unused' })).toBe(
+ 'Here is a partial that takes a correct.'
+ )
+ })
+
+ it('supports hyphenated variable names', () => {
+ const content = 'This partial has {{ .my-var }}, {{ .another_var }}, and {{ .myVar123 }}.'
+ expect(
+ substitutePartialVars(content, {
+ 'my-var': 'hyphenated value',
+ another_var: 'underscored value',
+ myVar123: 'alphanumeric value',
+ })
+ ).toBe('This partial has hyphenated value, underscored value, and alphanumeric value.')
+ })
+
+ it('handles values containing $ replacement patterns literally', () => {
+ expect(substitutePartialVars('Hello {{ .name }}', { name: '$& is literal' })).toBe(
+ 'Hello $& is literal'
+ )
+ })
+
+ it('handles keys containing regex metacharacters', () => {
+ expect(substitutePartialVars('Hello {{ .a.b }}', { 'a.b': 'world' })).toBe('Hello world')
+ })
+})
+
+describe('parsePartialVariables', () => {
+ it('returns undefined when variables are omitted', () => {
+ expect(parsePartialVariables(undefined)).toBeUndefined()
+ })
+
+ it('parses JSON object strings', () => {
+ expect(parsePartialVariables('{ "product": "Auth" }')).toEqual({
+ product: 'Auth',
+ })
+ })
+
+ it('accepts already-parsed objects', () => {
+ expect(parsePartialVariables({ product: 'Auth' })).toEqual({
+ product: 'Auth',
+ })
+ })
+
+ it('throws on non-string values', () => {
+ expect(() => parsePartialVariables('{ "var": [0, 1, 2] }')).toThrow(/valid JSON/)
+ })
+})
diff --git a/apps/docs/lib/partials.utils.ts b/apps/docs/lib/partials.utils.ts
new file mode 100644
index 00000000000..31ea320d81c
--- /dev/null
+++ b/apps/docs/lib/partials.utils.ts
@@ -0,0 +1,70 @@
+/**
+ * Shared $Partial variable substitution for the MDX runtime pipeline and the
+ * markdown export pipeline.
+ */
+
+/**
+ * Substitutes provided variables into partial content. Variable substitution is
+ * optional: any variable referenced in the content but not provided is replaced
+ * with an empty string, and any variable provided but not referenced is ignored.
+ * A leading `\` escape (`\{{ .var }}`) opts a placeholder out of substitution.
+ */
+export function substitutePartialVars(
+ content: string,
+ vars: Record<string, string> | undefined
+): string {
+ for (const [key, value] of Object.entries(vars ?? {})) {
+ const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+ content = content.replace(
+ new RegExp(`(?<!\\\\)\\{\\{\\s*\\.${escapedKey}\\s*\\}\\}`, 'g'),
+ () => value
+ )
+ }
+
+ content = content.replace(/(?<!\\)\{\{\s*\.[\w-]+\s*\}\}/g, '')
+ return content
+}
+
+function assertStringValues(parsed: unknown): asserts parsed is Record<string, string> {
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
+ throw new Error('Invalid $Partial variables: must be valid JSON containing only string values')
+ }
+
+ for (const value of Object.values(parsed)) {
+ if (typeof value !== 'string') {
+ throw new Error(
+ 'Invalid $Partial variables: must be valid JSON containing only string values'
+ )
+ }
+ }
+}
+
+/**
+ * Parses the `variables` prop from a `$Partial` node. Accepts a JSON object
+ * string (from MDX attribute expressions) or an already-parsed object.
+ */
+export function parsePartialVariables(raw: unknown): Record<string, string> | undefined {
+ if (raw === undefined || raw === null || raw === true) {
+ return undefined
+ }
+
+ if (typeof raw === 'object') {
+ assertStringValues(raw)
+ return raw
+ }
+
+ if (typeof raw !== 'string') {
+ throw new Error('Invalid $Partial variables: must be valid JSON containing only string values')
+ }
+
+ try {
+ const parsed: unknown = JSON.parse(raw)
+ assertStringValues(parsed)
+ return parsed
+ } catch (error) {
+ if (error instanceof Error && error.message.startsWith('Invalid $Partial variables')) {
+ throw error
+ }
+ throw new Error('Invalid $Partial variables: must be valid JSON containing only string values')
+ }
+}