The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: code blocks (#34427)
Charisc4afb754615a
diff --git a/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx b/apps/docs/content/guides/getting-started/tutorials/with-angular.mdxindex 36d2d5b4f63..384950af5b9 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx@@ -39,7 +39,9 @@ And finally we want to save the environment variables in the `src/environments/eAll we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).These variables will be exposed on the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```ts src/environments/environment.ts+<$CodeTabs>++```ts name=src/environments/environment.tsexport const environment = {production: false,supabaseUrl: 'YOUR_SUPABASE_URL',@@ -47,9 +49,13 @@ export const environment = {}```+</$CodeTabs>+Now that we have the API credentials in place, let's create a `SupabaseService` with `ng g s supabase` to initialize the Supabase client and implement functions to communicate with the Supabase API.-```ts src/app/supabase.service.ts+<$CodeTabs>++```ts name=src/app/supabase.service.tsimport { Injectable } from '@angular/core'import {AuthChangeEvent,@@ -125,6 +131,8 @@ export class SupabaseService {}```+</$CodeTabs>+Optionally, update [src/styles.css](https://raw.githubusercontent.com/supabase/supabase/master/examples/user-management/angular-user-management/src/styles.css) to style the app.### Set up a login component@@ -132,7 +140,9 @@ Optionally, update [src/styles.css](https://raw.githubusercontent.com/supabase/sLet's set up an Angular component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.Create an `AuthComponent` with `ng g c auth` Angular CLI command.-```ts src/app/auth/auth.component.ts+<$CodeTabs>++```ts name=src/app/auth/auth.component.tsimport { Component } from '@angular/core'import { FormBuilder } from '@angular/forms'import { SupabaseService } from '../supabase.service'@@ -173,7 +183,7 @@ export class AuthComponent {}```-```html src/app/auth/auth.component.html+```html name=src/app/auth/auth.component.html<div class="row flex-center flex"><div class="col-6 form-widget" aria-live="polite"><h1 class="header">Supabase + Angular</h1>@@ -199,12 +209,16 @@ export class AuthComponent {</div>```+</$CodeTabs>+### Account pageUsers also need a way to edit their profile details and manage their accounts after signing in.Create an `AccountComponent` with the `ng g c account` Angular CLI command.-```ts src/app/account/account.component.ts+<$CodeTabs>++```ts name=src/app/account/account.component.tsimport { Component, Input, OnInit } from '@angular/core'import { FormBuilder } from '@angular/forms'import { AuthSession } from '@supabase/supabase-js'@@ -297,7 +311,7 @@ export class AccountComponent implements OnInit {}```-```html src/app/account/account.component.html+```html name=src/app/account/account.component.html<form [formGroup]="updateProfileForm" (ngSubmit)="updateProfile()" class="form-widget"><div><label for="email">Email</label>@@ -324,11 +338,15 @@ export class AccountComponent implements OnInit {</form>```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `AppComponent`:-```ts src/app/app.component.ts+<$CodeTabs>++```ts name=src/app/app.component.tsimport { Component, OnInit } from '@angular/core'import { SupabaseService } from './supabase.service'@@ -350,7 +368,7 @@ export class AppComponent implements OnInit {}```-```html src/app/app.component.html+```html name=src/app/app.component.html<div class="container" style="padding: 50px 0 100px 0"><app-account *ngIf="session; else auth" [session]="session"></app-account><ng-template #auth>@@ -359,9 +377,13 @@ export class AppComponent implements OnInit {</div>```+</$CodeTabs>+`app.module.ts` also needs to be modified to include the `ReactiveFormsModule` from the `@angular/forms` package.-```ts src/app/app.module.ts+<$CodeTabs>++```ts name=src/app/app.module.tsimport { NgModule } from '@angular/core'import { BrowserModule } from '@angular/platform-browser'@@ -380,6 +402,8 @@ import { AvatarComponent } from './avatar/avatar.component'export class AppModule {}```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -399,7 +423,9 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for maLet's create an avatar for the user so that they can upload a profile photo.Create an `AvatarComponent` with `ng g c avatar` Angular CLI command.-```ts src/app/avatar/avatar.component.ts+<$CodeTabs>++```ts name=src/app/avatar/avatar.component.tsimport { Component, EventEmitter, Input, Output } from '@angular/core'import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser'import { SupabaseService } from '../supabase.service'@@ -464,7 +490,7 @@ export class AvatarComponent {}```-```html src/app/avatar/avatar.component.html+```html name=src/app/avatar/avatar.component.html<div><img*ngIf="_avatarUrl"@@ -490,20 +516,28 @@ export class AvatarComponent {</div>```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget on top of the `AccountComponent` HTML template:-```html src/app/account.component.html+<$CodeTabs>++```html name=src/app/account.component.html<form [formGroup]="updateProfileForm" (ngSubmit)="updateProfile()" class="form-widget"><app-avatar [avatarUrl]="this.avatarUrl" (upload)="updateAvatar($event)"> </app-avatar><!-- input fields --></form>```+</$CodeTabs>+And add an `updateAvatar` function along with an `avatarUrl` getter to the `AccountComponent` typescript file:-```ts src/app/account.component.ts+<$CodeTabs>++```ts name=src/app/account.component.ts@Component({selector: 'app-account',templateUrl: './account.component.html',@@ -525,4 +559,6 @@ export class AccountComponent implements OnInit {}```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx b/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdxindex f828afed14c..dea1fad9bd9 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx@@ -51,7 +51,9 @@ These variables are safe to expose in your Expo app since Supabase has><TabPanel id="async-storage" label="AsyncStorage">- ```ts lib/supabase.ts+ <$CodeTabs>++ ```ts name=lib/supabase.tsimport AsyncStorage from '@react-native-async-storage/async-storage'import { createClient } from '@supabase/supabase-js'@@ -68,6 +70,8 @@ These variables are safe to expose in your Expo app since Supabase has})```+ </$CodeTabs>+</TabPanel><TabPanel id="secure-store" label="SecureStore">@@ -90,7 +94,9 @@ These variables are safe to expose in your Expo app since Supabase hasImplement a `LargeSecureStore` class to pass in as Auth storage for the `supabase-js` client:- ```ts lib/supabase.ts+ <$CodeTabs>++ ```ts name=lib/supabase.tsimport { createClient } from "@supabase/supabase-js";import AsyncStorage from "@react-native-async-storage/async-storage";import * as SecureStore from 'expo-secure-store';@@ -156,6 +162,8 @@ These variables are safe to expose in your Expo app since Supabase has});```+ </$CodeTabs>+</TabPanel></Tabs>@@ -164,7 +172,9 @@ These variables are safe to expose in your Expo app since Supabase hasLet's set up a React Native component to manage logins and sign ups.Users would be able to sign in with their email and password.-```tsx components/Auth.tsx+<$CodeTabs>++```tsx name=components/Auth.tsximport React, { useState } from 'react'import { Alert, StyleSheet, View, AppState } from 'react-native'import { supabase } from '../lib/supabase'@@ -262,6 +272,8 @@ const styles = StyleSheet.create({})```+</$CodeTabs>+<Admonition type="note">By default Supabase Auth requires email verification before a session is created for the users. To support email verification you need to [implement deep link handling](/docs/guides/auth/native-mobile-deep-linking?platform=react-native)!@@ -276,7 +288,9 @@ After a user is signed in we can allow them to edit their profile details and maLet's create a new component for that called `Account.tsx`.-```tsx components/Account.tsx+<$CodeTabs>++```tsx name=components/Account.tsximport { useState, useEffect } from 'react'import { supabase } from '../lib/supabase'import { StyleSheet, View, Alert } from 'react-native'@@ -399,11 +413,15 @@ const styles = StyleSheet.create({})```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `App.tsx`:-```tsx App.tsx+<$CodeTabs>++```tsx name=App.tsximport { useState, useEffect } from 'react'import { supabase } from './lib/supabase'import Auth from './components/Auth'@@ -432,6 +450,8 @@ export default function App() {}```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -458,9 +478,9 @@ npx expo install expo-image-pickerLet's create an avatar for the user so that they can upload a profile photo.We can start by creating a new component:-{/* <!-- vale off --> */}+<$CodeTabs>-```tsx components/Avatar.tsx+```tsx name=components/Avatar.tsximport { useState, useEffect } from 'react'import { supabase } from '../lib/supabase'import { StyleSheet, View, Alert, Image, Button } from 'react-native'@@ -593,13 +613,15 @@ const styles = StyleSheet.create({})```-{/* <!-- vale on --> */}+</$CodeTabs>### Add the new widgetAnd then we can add the widget to the Account page:-```tsx components/Account.tsx+<$CodeTabs>++```tsx name=components/Account.tsx// Import the new componentimport Avatar from './Avatar'@@ -623,6 +645,8 @@ return (// ...```+</$CodeTabs>+Now you will need to run the prebuild command to get the application working on your chosen platform.```bashdiff --git a/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx b/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdxindex 3334b36d7a1..6b19272384b 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx@@ -65,7 +65,9 @@ Edit the `ios/Runner/Info.plist` file.Add `CFBundleURLTypes` to enable deep linking:-```xml ios/Runner/Info.plist"+<$CodeTabs>++```xml name=ios/Runner/Info.plist"<!-- ... other tags --><plist><dict>@@ -88,13 +90,17 @@ Add `CFBundleURLTypes` to enable deep linking:</plist>```+</$CodeTabs>+</TabPanel><TabPanel id="android" label="Android">Edit the `android/app/src/main/AndroidManifest.xml` file.Add an intent-filter to enable deep linking:-```xml android/app/src/main/AndroidManifest.xml+<$CodeTabs>++```xml name=android/app/src/main/AndroidManifest.xml<manifest ...><!-- ... other tags --><application ...>@@ -117,6 +123,8 @@ Add an intent-filter to enable deep linking:</manifest>```+</$CodeTabs>+</TabPanel><TabPanel id="web" label="Web">Supabase redirects do not work with Flutter's [default URL strategy](https://docs.flutter.dev/ui/navigation/url-strategies).@@ -138,7 +146,9 @@ void main() {Now that we have deep links ready let's initialize the Supabase client inside our `main` function with the API credentials that you copied [earlier](#get-the-api-keys). These variables will be exposed on the app, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```dart lib/main.dart+<$CodeTabs>++```dart name=lib/main.dartimport 'package:flutter/material.dart';import 'package:supabase_flutter/supabase_flutter.dart';@@ -175,6 +185,8 @@ extension ContextExtension on BuildContext {}```+</$CodeTabs>+Notice that we have a `showSnackBar` extension method that we will use to show snack bars in the app. You could define this method in a separate file and import it where needed, but for simplicity, we will define it here.### Set up a login page@@ -183,7 +195,9 @@ Let's create a Flutter widget to manage logins and sign ups. We will use Magic LNotice that this page sets up a listener on the user's auth state using `onAuthStateChange`. A new event will fire when the user comes back to the app by clicking their magic link, which this page can catch and redirect the user accordingly.-```dart lib/pages/login_page.dart+<$CodeTabs>++```dart name=lib/pages/login_page.dartimport 'dart:async';import 'package:flutter/foundation.dart';@@ -291,12 +305,16 @@ class _LoginPageState extends State<LoginPage> {}```+</$CodeTabs>+### Set up account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new widget called `account_page.dart` for that.-```dart lib/pages/account_page.dart"+<$CodeTabs>++```dart name=lib/pages/account_page.dart"import 'package:flutter/material.dart';import 'package:supabase_flutter/supabase_flutter.dart';import 'package:supabase_quickstart/main.dart';@@ -437,13 +455,17 @@ class _AccountPageState extends State<AccountPage> {}```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `lib/main.dart`.The `home` of the `MaterialApp`, meaning the initial page shown to the user, will be the `LoginPage` if the user is not authenticated, and the `AccountPage` if the user is authenticated.We also included some theming to make the app look a bit nicer.-```dart lib/main.dart+<$CodeTabs>++```dart name=lib/main.dartimport 'package:flutter/material.dart';import 'package:supabase_flutter/supabase_flutter.dart';import 'package:supabase_quickstart/pages/account_page.dart';@@ -501,6 +523,8 @@ extension ContextExtension on BuildContext {}```+</$CodeTabs>+Once that's done, run this in a terminal window to launch on Android or iOS:```bash@@ -548,7 +572,9 @@ Once you are done with all of the above, it is time to dive into coding.Let's create an avatar for the user so that they can upload a profile photo.We can start by creating a new component:-```dart lib/components/avatar.dart+<$CodeTabs>++```dart name=lib/components/avatar.dartimport 'package:flutter/material.dart';import 'package:image_picker/image_picker.dart';import 'package:supabase_flutter/supabase_flutter.dart';@@ -640,11 +666,15 @@ class _AvatarState extends State<Avatar> {}```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page as well as some logic to update the `avatar_url` whenever the user uploads a new avatar.-```dart lib/pages/account_page.dart+<$CodeTabs>++```dart name=lib/pages/account_page.dartimport 'package:flutter/material.dart';import 'package:supabase_flutter/supabase_flutter.dart';import 'package:supabase_quickstart/components/avatar.dart';@@ -820,6 +850,8 @@ class _AccountPageState extends State<AccountPage> {}```+</$CodeTabs>+Congratulations, you've built a fully functional user management app using Flutter and Supabase!## See alsodiff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdxindex 06379df40d8..e366f24d0c7 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx@@ -40,7 +40,9 @@ And finally, we want to save the environment variables in the `src/environments/All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).These variables will be exposed on the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```ts environment.ts+<$CodeTabs>++```ts name=environment.tsexport const environment = {production: false,supabaseUrl: 'YOUR_SUPABASE_URL',@@ -48,9 +50,13 @@ export const environment = {}```+</$CodeTabs>+Now that we have the API credentials in place, let's create a `SupabaseService` with `ionic g s supabase` to initialize the Supabase client and implement functions to communicate with the Supabase API.-```ts src/app/supabase.service.ts+<$CodeTabs>++```ts name=src/app/supabase.service.tsimport { Injectable } from '@angular/core'import { LoadingController, ToastController } from '@ionic/angular'import { AuthChangeEvent, createClient, Session, SupabaseClient } from '@supabase/supabase-js'@@ -133,6 +139,8 @@ export class SupabaseService {}```+</$CodeTabs>+### Set up a login routeLet's set up a route to manage logins and signups. We'll use Magic Links so users can sign in with their email without using passwords.@@ -144,7 +152,9 @@ This guide will show the template inline, but the example app will have `templat</Admonition>-```ts src/app/login/login.page.ts+<$CodeTabs>++```ts name=src/app/login/login.page.tsimport { Component, OnInit } from '@angular/core'import { SupabaseService } from '../supabase.service'@@ -201,12 +211,16 @@ export class LoginPage {}```+</$CodeTabs>+### Account pageAfter a user is signed in, we can allow them to edit their profile details and manage their account.Create an `AccountComponent` with `ionic g page account` Ionic CLI command.-```ts src/app/account.page.ts+<$CodeTabs>++```ts name=src/app/account.page.tsimport { Component, OnInit } from '@angular/core'import { Router } from '@angular/router'import { Profile, SupabaseService } from '../supabase.service'@@ -308,11 +322,15 @@ export class AccountPage implements OnInit {}```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `AppComponent`:-```ts src/app/app.component.ts+<$CodeTabs>++```ts name=src/app/app.component.tsimport { Component } from '@angular/core'import { Router } from '@angular/router'import { SupabaseService } from './supabase.service'@@ -341,9 +359,13 @@ export class AppComponent {}```+</$CodeTabs>+Then update the `AppRoutingModule`-```ts src/app/app-routing.module.ts"+<$CodeTabs>++```ts name=src/app/app-routing.module.ts"import { NgModule } from '@angular/core'import { PreloadAllModules, RouterModule, Routes } from '@angular/router'@@ -369,6 +391,8 @@ const routes: Routes = [export class AppRoutingModule {}```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -399,7 +423,9 @@ Ionic PWA elements is a companion package that will polyfill certain browser APIWith those packages installed, we can update our `main.ts` to include an additional bootstrapping call for the Ionic PWA Elements.-```ts src/main.ts+<$CodeTabs>++```ts name=src/main.tsimport { enableProdMode } from '@angular/core'import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'@@ -417,13 +443,17 @@ platformBrowserDynamic().catch((err) => console.log(err))```+</$CodeTabs>+Then create an `AvatarComponent` with this Ionic CLI command:```bashionic g component avatar --module=/src/app/account/account.module.ts --create-module```-```ts src/app/avatar.component.ts+<$CodeTabs>++```ts name=src/app/avatar.component.tsimport { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'import { SupabaseService } from '../supabase.service'@@ -534,11 +564,15 @@ export class AvatarComponent {}```+</$CodeTabs>+### Add the new widgetAnd then, we can add the widget on top of the `AccountComponent` HTML template:-```ts src/app/account.component.ts+<$CodeTabs>++```ts name=src/app/account.component.tstemplate: `<ion-header><ion-toolbar>@@ -556,6 +590,8 @@ template: `````+</$CodeTabs>+At this stage, you have a fully functional application!## See alsodiff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdxindex d4530d110de..1eeafd56115 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx@@ -39,15 +39,21 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env`.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envREACT_APP_SUPABASE_URL=YOUR_SUPABASE_URLREACT_APP_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```+</$CodeTabs>+Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposedon the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```js src/supabaseClient.js+<$CodeTabs>++```js name=src/supabaseClient.jsimport { createClient } from '@supabase/supabase-js'const supabaseUrl = process.env.REACT_APP_SUPABASE_URL@@ -56,11 +62,15 @@ const supabaseAnonKey = process.env.REACT_APP_SUPABASE_ANON_KEYexport const supabase = createClient(supabaseUrl, supabaseAnonKey)```+</$CodeTabs>+### Set up a login routeLet's set up a React component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.-```jsx /src/pages/Login.tsx+<$CodeTabs>++```jsx name=/src/pages/Login.tsximport { useState } from 'react';import {IonButton,@@ -133,13 +143,17 @@ export function LoginPage() {}```+</$CodeTabs>+### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new component for that called `Account.tsx`.-```jsx src/pages/Account.tsx+<$CodeTabs>++```jsx name=src/pages/Account.tsximport {IonButton,IonContent,@@ -289,11 +303,15 @@ export function AccountPage() {}```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `App.tsx`:-```jsx src/App.tsx+<$CodeTabs>++```jsx name=src/App.tsximport { Redirect, Route } from 'react-router-dom'import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react'import { IonReactRouter } from '@ionic/react-router'@@ -341,6 +359,8 @@ const App: React.FC = () => {export default App```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -369,7 +389,9 @@ Ionic PWA elements is a companion package that will polyfill certain browser APIWith those packages installed we can update our `index.tsx` to include an additional bootstrapping call for the Ionic PWA Elements.-```ts src/index.tsx+<$CodeTabs>++```ts name=src/index.tsximport React from 'react'import ReactDOM from 'react-dom'import App from './App'@@ -390,9 +412,13 @@ serviceWorkerRegistration.unregister()reportWebVitals()```+</$CodeTabs>+Then create an `AvatarComponent`.-```jsx src/components/Avatar.tsx+<$CodeTabs>++```jsx name=src/components/Avatar.tsximport { IonIcon } from '@ionic/react';import { person } from 'ionicons/icons';import { Camera, CameraResultType } from '@capacitor/camera';@@ -471,11 +497,15 @@ export function Avatar({}```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page:-```jsx src/pages/Account.tsx+<$CodeTabs>++```jsx name=src/pages/Account.tsx// Import the new componentimport { Avatar } from '../components/Avatar';@@ -493,4 +523,6 @@ return (<Avatar url={profile.avatar_url} onUpload={updateProfile}></Avatar>```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdxindex 01c398e52c0..937a170e67f 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx@@ -39,15 +39,21 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env`.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envVUE_APP_SUPABASE_URL=YOUR_SUPABASE_URLVUE_APP_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```+</$CodeTabs>+Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposedon the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```js src/supabase.ts"+<$CodeTabs>++```js name=src/supabase.ts"import { createClient } from '@supabase/supabase-js';const supabaseUrl = process.env.VUE_APP_SUPABASE_URL as string;@@ -56,11 +62,15 @@ const supabaseAnonKey = process.env.VUE_APP_SUPABASE_ANON_KEY as string;export const supabase = createClient(supabaseUrl, supabaseAnonKey);```+</$CodeTabs>+### Set up a login routeLet's set up a Vue component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.-```html /src/views/Login.vue+<$CodeTabs>++```html name=/src/views/Login.vue<template><ion-page><ion-header>@@ -149,13 +159,17 @@ Let's set up a Vue component to manage logins and sign ups. We'll use Magic Link</script>```+</$CodeTabs>+### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new component for that called `Account.vue`.-```html src/views/Account.vue+<$CodeTabs>++```html name=src/views/Account.vue<template><ion-page><ion-header>@@ -310,11 +324,15 @@ Let's create a new component for that called `Account.vue`.</script>```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `App.vue` and our routes:-```ts src/router.index.ts+<$CodeTabs>++```ts name=src/router.index.tsimport { createRouter, createWebHistory } from '@ionic/vue-router'import { RouteRecordRaw } from 'vue-router'import LoginPage from '../views/Login.vue'@@ -340,7 +358,7 @@ const router = createRouter({export default router```-```html src/App.vue+```html name=src/App.vue<template><ion-app><ion-router-outlet />@@ -374,6 +392,8 @@ export default router</script>```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -402,7 +422,9 @@ Ionic PWA elements is a companion package that will polyfill certain browser APIWith those packages installed we can update our `main.ts` to include an additional bootstrapping call for the Ionic PWA Elements.-```ts src/main.tsx"+<$CodeTabs>++```ts name=src/main.tsx"import { createApp } from 'vue'import App from './App.vue'import router from './router'@@ -423,9 +445,13 @@ router.isReady().then(() => {})```+</$CodeTabs>+Then create an `AvatarComponent`.-```html src/components/Avatar.vue+<$CodeTabs>++```html name=src/components/Avatar.vue<template><div class="avatar"><div class="avatar_wrapper" @click="uploadAvatar">@@ -524,11 +550,15 @@ Then create an `AvatarComponent`.</style>```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page:-```html src/views/Account.vue+<$CodeTabs>++```html name=src/views/Account.vue<template><ion-page><ion-header>@@ -553,4 +583,6 @@ export default defineComponent({</script>```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx b/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdxindex 8b38dc47783..20e45f4e4a7 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx@@ -38,11 +38,15 @@ npm install @nuxtjs/supabase --save-devAnd finally we want to save the environment variables in a `.env`.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envSUPABASE_URL="YOUR_SUPABASE_URL"SUPABASE_KEY="YOUR_SUPABASE_ANON_KEY"```+</$CodeTabs>+These variables will be exposed on the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.Amazing thing about [Nuxt Supabase](https://supabase.nuxtjs.org/) is that setting environment variables is all we need to do in order to start using Supabase.No need to initialize Supabase. The library will take care of it automatically.@@ -52,7 +56,9 @@ No need to initialize Supabase. The library will take care of it automatically.An optional step is to update the CSS file `assets/main.css` to make the app look nice.You can find the full contents of this file [here](https://github.com/supabase-community/nuxt3-quickstarter/blob/main/assets/main.css).-```typescript nuxt.config.ts+<$CodeTabs>++```typescript name=nuxt.config.tsimport { defineNuxtConfig } from 'nuxt'// https://v3.nuxtjs.org/api/configuration/nuxt.config@@ -62,11 +68,15 @@ export default defineNuxtConfig({})```+</$CodeTabs>+### Set up Auth componentLet's set up a Vue component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.-```vue /components/Auth.vue+<$CodeTabs>++```vue name=/components/Auth.vue<script setup>const supabase = useSupabaseClient()@@ -108,6 +118,8 @@ const handleLogin = async () => {</template>```+</$CodeTabs>+### User stateTo access the user information, use the composable [`useSupabaseUser`](https://supabase.nuxtjs.org/usage/composables/usesupabaseuser) provided by the Supabase Nuxt module.@@ -117,7 +129,9 @@ To access the user information, use the composable [`useSupabaseUser`](https://sAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new component for that called `Account.vue`.-```vue components/Account.vue+<$CodeTabs>++```vue name=components/Account.vue<script setup>const supabase = useSupabaseClient()@@ -212,11 +226,15 @@ async function signOut() {</template>```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `app.vue`:-```vue app.vue+<$CodeTabs>++```vue name=app.vue<script setup>const user = useSupabaseUser()</script>@@ -229,6 +247,8 @@ const user = useSupabaseUser()</template>```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -247,7 +267,9 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for maLet's create an avatar for the user so that they can upload a profile photo. We can start by creating a new component:-```vue components/Avatar.vue+<$CodeTabs>++```vue name=components/Avatar.vue<script setup>const props = defineProps(['path'])const { path } = toRefs(props)@@ -334,11 +356,15 @@ watch(path, () => {</template>```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page:-```vue components/Account.vue+<$CodeTabs>++```vue name=components/Account.vue<script setup>const supabase = useSupabaseClient()@@ -434,4 +460,6 @@ async function signOut() {</template>```+</$CodeTabs>+That is it! You should now be able to upload a profile photo to Supabase Storage and you have a fully functional application.diff --git a/apps/docs/content/guides/getting-started/tutorials/with-react.mdx b/apps/docs/content/guides/getting-started/tutorials/with-react.mdxindex 5322666e06f..f1089155165 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-react.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-react.mdx@@ -38,17 +38,23 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env.local` file.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envVITE_SUPABASE_URL=YOUR_SUPABASE_URLVITE_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```+</$CodeTabs>+Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposedon the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.Create and edit `src/supabaseClient.js`:-```js src/supabaseClient.js+<$CodeTabs>++```js name=src/supabaseClient.jsimport { createClient } from '@supabase/supabase-js'const supabaseUrl = import.meta.env.VITE_SUPABASE_URL@@ -57,6 +63,8 @@ const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEYexport const supabase = createClient(supabaseUrl, supabaseAnonKey)```+</$CodeTabs>+### App styling (optional)An optional step is to update the CSS file `src/index.css` to make the app look nice.@@ -68,7 +76,9 @@ Let's set up a React component to manage logins and sign ups. We'll use Magic LiCreate and edit `src/Auth.jsx`:-```jsx src/Auth.jsx+<$CodeTabs>++```jsx name=src/Auth.jsximport { useState } from 'react'import { supabase } from './supabaseClient'@@ -118,13 +128,17 @@ export default function Auth() {}```+</$CodeTabs>+### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new component for that called `src/Account.jsx`.-```jsx src/Account.jsx+<$CodeTabs>++```jsx name=src/Account.jsximport { useState, useEffect } from 'react'import { supabase } from './supabaseClient'@@ -232,11 +246,15 @@ export default function Account({ session }) {}```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `src/App.jsx`:-```jsx src/App.jsx+<$CodeTabs>++```jsx name=src/App.jsximport './App.css'import { useState, useEffect } from 'react'import { supabase } from './supabaseClient'@@ -266,6 +284,8 @@ function App() {export default App```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -286,7 +306,9 @@ Let's create an avatar for the user so that they can upload a profile photo. WeCreate and edit `src/Avatar.jsx`:-```jsx src/Avatar.jsx+<$CodeTabs>++```jsx name=src/Avatar.jsximport { useEffect, useState } from 'react'import { supabase } from './supabaseClient'@@ -371,11 +393,15 @@ export default function Avatar({ url, size, onUpload }) {}```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page at `src/Account.jsx`:-```jsx src/Account.jsx+<$CodeTabs>++```jsx name=src/Account.jsx// Import the new componentimport Avatar from './Avatar'@@ -396,4 +422,6 @@ return ()```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx b/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdxindex ab535b32bae..1c01d3c81e3 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx@@ -105,15 +105,21 @@ Say, **yes** and it will setup the Supabase client in your app and also provideNext, we want to save the environment variables in a `.env`.We need the `API URL` as well as the `anon` and `jwt_secret` keys that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envSUPABASE_URL=YOUR_SUPABASE_URLSUPABASE_KEY=YOUR_SUPABASE_ANON_KEYSUPABASE_JWT_SECRET=YOUR_SUPABASE_JWT_SECRET```+</$CodeTabs>+And finally, you will also need to save **just** the `web side` environment variables to the `redwood.toml`.-```bash redwood.toml+<$CodeTabs>++```bash name=redwood.toml[web]title = "Supabase Redwood Tutorial"port = 8910@@ -125,13 +131,17 @@ And finally, you will also need to save **just** the `web side` environment variopen = true```+</$CodeTabs>+These variables will be exposed on the browser, and that's completely fine.They allow your web app to initialize the Supabase client with your public anon keysince we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.You'll see these being used to configure your Supabase client in `web/src/App.js`:-```js web/src/App.js+<$CodeTabs>++```js name=web/src/App.js// ... Redwood importsimport { AuthProvider } from '@redwoodjs/auth'import { createClient } from '@supabase/supabase-js'@@ -155,6 +165,8 @@ const App = () => (export default App```+</$CodeTabs>+### App styling (optional)An optional step is to update the CSS file `web/src/index.css` to make the app look nice.@@ -199,7 +211,9 @@ You can stop the `dev` server if you want; to see your changes, just be sure toYou should see the `Home` page route in `web/src/Routes.js`:-```bash web/src/Routes.js+<$CodeTabs>++```bash name=web/src/Routes.jsimport { Router, Route } from '@redwoodjs/router'const Routes = () => {@@ -214,6 +228,8 @@ const Routes = () => {export default Routes```+</$CodeTabs>+### Set up a login componentLet's set up a Redwood component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.@@ -230,7 +246,9 @@ yarn rw g component authNow, update the `Auth.js` component to contain:-```jsx /web/src/components/Auth/Auth.js+<$CodeTabs>++```jsx name=/web/src/components/Auth/Auth.jsimport { useState } from 'react'import { useAuth } from '@redwoodjs/auth'@@ -286,6 +304,8 @@ const Auth = () => {export default Auth```+</$CodeTabs>+### Set up an account componentAfter a user is signed in we can allow them to edit their profile details and manage their account.@@ -303,7 +323,9 @@ yarn rw g component accountAnd then update the file to contain:-```jsx web/src/components/Account/Account.js+<$CodeTabs>++```jsx name=web/src/components/Account/Account.jsimport { useState, useEffect } from 'react'import { useAuth } from '@redwoodjs/auth'@@ -427,6 +449,8 @@ const Account = () => {export default Account```+</$CodeTabs>+You'll see the use of `useAuth()` several times. Redwood's `useAuth` hook provides convenient ways to access`logIn`, `logOut`, `currentUser`, and access the `supabase` authenticate client. We'll use it to get an instanceof the Supabase client to interact with your API.@@ -435,7 +459,9 @@ of the Supabase client to interact with your API.Now that we have all the components in place, let's update your `HomePage` page to use them:-```jsx web/src/pages/HomePage/HomePage.js+<$CodeTabs>++```jsx name=web/src/pages/HomePage/HomePage.jsimport { useAuth } from '@redwoodjs/auth'import { MetaTags } from '@redwoodjs/web'@@ -456,6 +482,8 @@ const HomePage = () => {export default HomePage```+</$CodeTabs>+<Admonition type="note">What we're doing here is showing the sign in form if you aren't logged in and your account profile if you are.@@ -492,7 +520,9 @@ yarn rw g component avatarNow, update your Avatar component to contain the following widget:-```jsx web/src/components/Avatar/Avatar.js+<$CodeTabs>++```jsx name=web/src/components/Avatar/Avatar.jsimport { useEffect, useState } from 'react'import { useAuth } from '@redwoodjs/auth'@@ -581,11 +611,15 @@ const Avatar = ({ url, size, onUpload }) => {export default Avatar```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account component:-```jsx web/src/components/Account/Account.js+<$CodeTabs>++```jsx name=web/src/components/Account/Account.js// Import the new componentimport Avatar from 'src/components/Avatar'@@ -607,6 +641,8 @@ return ()```+</$CodeTabs>+At this stage you have a fully functional application!## See alsodiff --git a/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx b/apps/docs/content/guides/getting-started/tutorials/with-refine.mdxindex 0466ffdf151..159d8bceec3 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx@@ -67,7 +67,9 @@ The `create refine-app` generated a Supabase client for us in the `src/utility/sWe'll update it with environment variables managed by Vite:-```ts src/utility/supabaseClient.ts+<$CodeTabs>++```ts name=src/utility/supabaseClient.tsimport { createClient } from '@refinedev/supabase'const supabaseUrl = import.meta.env.VITE_SUPABASE_URL@@ -83,6 +85,8 @@ export const supabaseClient = createClient(supabaseUrl, supabaseAnonKey, {})```+</$CodeTabs>+And then, we want to save the environment variables in a `.env.local` file. All you need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).```bash .env.local@@ -101,7 +105,9 @@ In order for us to add login and user profile pages in this App, we have to tweaThe `App.tsx` file initially looks like this:-```tsx src/App.tsx+<$CodeTabs>++```tsx name=src/App.tsximport { Refine, WelcomePage } from '@refinedev/core'import { RefineKbar, RefineKbarProvider } from '@refinedev/kbar'import routerBindings, {@@ -144,6 +150,8 @@ function App() {export default App```+</$CodeTabs>+We'd like to focus on the [`<Refine />`](https://refine.dev/docs/api-reference/core/components/refine-config/) component, which comes with several props passed to it. Notice the `dataProvider` prop. It uses a `dataProvider()` function with `supabaseClient` passed as argument to generate the data provider object. The `authProvider` object also uses `supabaseClient` in implementing its methods. You can look it up in `src/authProvider.ts` file.## Customize `authProvider`@@ -177,7 +185,9 @@ login: async ({ email }) => {We also want to remove `register`, `updatePassword`, `forgotPassword` and `getPermissions` properties, which are optional type members and also not necessary for our app. The final `authProvider` object looks like this:-```ts src/authProvider.ts+<$CodeTabs>++```ts name=src/authProvider.tsimport { AuthBindings } from '@refinedev/core'import { supabaseClient } from './utility'@@ -271,13 +281,17 @@ const authProvider: AuthBindings = {export default authProvider```+</$CodeTabs>+### Set up a login componentWe have chosen to use the headless refine core package that comes with no supported UI framework. So, let's set up a plain React component to manage logins and sign ups.Create and edit `src/components/auth.tsx`:-```ts src/components/auth.tsx+<$CodeTabs>++```ts name=src/components/auth.tsximport { useState } from 'react'import { useLogin } from '@refinedev/core'@@ -318,6 +332,8 @@ export default function Auth() {}```+</$CodeTabs>+Notice we are using the [`useLogin()`](https://refine.dev/docs/api-reference/core/hooks/authentication/useLogin/) refine auth hook to grab the `mutate: login` method to use inside `handleLogin()` function and `isLoading` state for our form submission. The `useLogin()` hook conveniently offers us access to `authProvider.login` method for authenticating the user with OTP.### Account page@@ -326,7 +342,9 @@ After a user is signed in we can allow them to edit their profile details and maLet's create a new component for that in `src/components/account.tsx`.-```tsx src/components/account.tsx+<$CodeTabs>++```tsx name=src/components/account.tsximport { BaseKey, useGetIdentity, useLogout } from '@refinedev/core'import { useForm } from '@refinedev/react-hook-form'@@ -396,6 +414,8 @@ export default function Account() {}```+</$CodeTabs>+Notice above that, we are using three refine hooks, namely the [`useGetIdentity()`](https://refine.dev/docs/api-reference/core/hooks/authentication/useGetIdentity/), [`useLogOut()`](https://refine.dev/docs/api-reference/core/hooks/authentication/useLogout/) and [`useForm()`](https://refine.dev/docs/packages/documentation/react-hook-form/useForm/) hooks.`useGetIdentity()` is a auth hook that gets the identity of the authenticated user. It grabs the current user by invoking the `authProvider.getIdentity` method under the hood.@@ -412,7 +432,9 @@ Now that we have all the components in place, let's define the routes for the paAdd the routes for `/login` with the `<Auth />` component and the routes for `index` path with the `<Account />` component. So, the final `App.tsx`:-```tsx src/App.tsx+<$CodeTabs>++```tsx name=src/App.tsximport { Authenticated, Refine } from '@refinedev/core'import { RefineKbar, RefineKbarProvider } from '@refinedev/kbar'import routerBindings, {@@ -469,6 +491,8 @@ function App() {export default App```+</$CodeTabs>+Let's test the App by running the server again:```bash@@ -489,7 +513,9 @@ Let's create an avatar for the user so that they can upload a profile photo. WeCreate and edit `src/components/avatar.tsx`:-```tsx src/components/avatar.tsx+<$CodeTabs>++```tsx name=src/components/avatar.tsximport { useEffect, useState } from 'react'import { supabaseClient } from '../utility/supabaseClient'@@ -582,11 +608,15 @@ export default function Avatar({ url, size, onUpload }: TAvatarProps) {}```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page at `src/components/account.tsx`:-```tsx src/components/account.tsx+<$CodeTabs>++```tsx name=src/components/account.tsx// Import the new componentsimport { Controller } from 'react-hook-form'import Avatar from './avatar'@@ -626,4 +656,6 @@ return ()```+</$CodeTabs>+At this stage, you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx b/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdxindex c006835208a..08cb3e10fff 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx@@ -37,15 +37,21 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env`.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envVITE_SUPABASE_URL=YOUR_SUPABASE_URLVITE_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```+</$CodeTabs>+Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposedon the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```tsx src/supabaseClient.tsx+<$CodeTabs>++```tsx name=src/supabaseClient.tsximport { createClient } from '@supabase/supabase-js'const supabaseUrl = import.meta.env.VITE_SUPABASE_URL@@ -54,6 +60,8 @@ const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEYexport const supabase = createClient(supabaseUrl, supabaseAnonKey)```+</$CodeTabs>+### App styling (optional)An optional step is to update the CSS file `src/index.css` to make the app look nice.@@ -63,7 +71,9 @@ You can find the full contents of this file [here](https://raw.githubusercontentLet's set up a SolidJS component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.-```jsx src/Auth.tsx+<$CodeTabs>++```jsx name=src/Auth.tsximport { createSignal } from 'solid-js'import { supabase } from './supabaseClient'@@ -117,13 +127,17 @@ export default function Auth() {}```+</$CodeTabs>+### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new component for that called `Account.tsx`.-```tsx src/Account.tsx+<$CodeTabs>++```tsx name=src/Account.tsximport { AuthSession } from '@supabase/supabase-js'import { Component, createEffect, createSignal } from 'solid-js'import { supabase } from './supabaseClient'@@ -238,11 +252,15 @@ const Account: Component<Props> = ({ session }) => {export default Account```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `App.tsx`:-```jsx src/App.tsx+<$CodeTabs>++```jsx name=src/App.tsximport { Component, createEffect, createSignal } from 'solid-js'import { supabase } from './supabaseClient'import { AuthSession } from '@supabase/supabase-js'@@ -272,6 +290,8 @@ const App: Component = () => {export default App```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -290,7 +310,9 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for maLet's create an avatar for the user so that they can upload a profile photo. We can start by creating a new component:-```jsx src/Avatar.tsx+<$CodeTabs>++```jsx name=src/Avatar.tsximport { Component, createEffect, createSignal, JSX } from 'solid-js'import { supabase } from './supabaseClient'@@ -389,11 +411,15 @@ const Avatar: Component<Props> = (props) => {export default Avatar```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page:-```jsx src/Account.tsx+<$CodeTabs>++```jsx name=src/Account.tsx// Import the new componentimport Avatar from './Avatar'@@ -415,4 +441,6 @@ return ()```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx b/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdxindex bfda75d7a71..9146ada103c 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx@@ -38,15 +38,21 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env`.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envVITE_SUPABASE_URL=YOUR_SUPABASE_URLVITE_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```+</$CodeTabs>+Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposedon the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```js src/supabaseClient.ts+<$CodeTabs>++```js name=src/supabaseClient.tsimport { createClient } from '@supabase/supabase-js'const supabaseUrl = import.meta.env.VITE_SUPABASE_URL@@ -55,6 +61,8 @@ const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEYexport const supabase = createClient(supabaseUrl, supabaseAnonKey)```+</$CodeTabs>+### App styling (optional)An optional step is to update the CSS file `src/app.css` to make the app look nice.@@ -64,7 +72,9 @@ You can find the full contents of this file [here](https://raw.githubusercontentLet's set up a Svelte component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.-```html src/lib/Auth.svelte+<$CodeTabs>++```html name=src/lib/Auth.svelte<script lang="ts">import { supabase } from '../supabaseClient'@@ -112,12 +122,16 @@ Let's set up a Svelte component to manage logins and sign ups. We'll use Magic L</div>```+</$CodeTabs>+### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Let's create a new component for that called `Account.svelte`.-```tsx src/lib/Account.svelte+<$CodeTabs>++```tsx name=src/lib/Account.svelte<script lang="ts">import { onMount } from 'svelte'import type { AuthSession } from '@supabase/supabase-js'@@ -209,11 +223,15 @@ Let's create a new component for that called `Account.svelte`.</form>```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `App.svelte`:-```html src/App.svelte+<$CodeTabs>++```html name=src/App.svelte<script lang="ts">import { onMount } from 'svelte'import { supabase } from './supabaseClient'@@ -243,6 +261,8 @@ Now that we have all the components in place, let's update `App.svelte`:</div>```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -267,7 +287,9 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for maLet's create an avatar for the user so that they can upload a profile photo. We can start by creating a new component:-```html src/lib/Avatar.svelte+<$CodeTabs>++```html name=src/lib/Avatar.svelte<script lang="ts">import { createEventDispatcher } from 'svelte'import { supabase } from '../supabaseClient'@@ -353,11 +375,15 @@ Let's create an avatar for the user so that they can upload a profile photo. We</div>```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page:-```html src/lib/Account.svelte+<$CodeTabs>++```html name=src/lib/Account.svelte<script lang="ts">// Import the new componentimport Avatar from './Avatar.svelte'@@ -371,4 +397,6 @@ And then we can add the widget to the Account page:</form>```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdxindex 9df43ff8bbb..333c69c04e5 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx@@ -38,11 +38,15 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env`.All we need are the `SUPABASE_URL` and the `SUPABASE_KEY` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envPUBLIC_SUPABASE_URL="YOUR_SUPABASE_URL"PUBLIC_SUPABASE_ANON_KEY="YOUR_SUPABASE_KEY"```+</$CodeTabs>+Optionally, add `src/styles.css` with the [CSS from the example](https://raw.githubusercontent.com/supabase/supabase/master/examples/user-management/sveltekit-user-management/src/styles.css).### Creating a Supabase client for SSR@@ -59,7 +63,9 @@ Creating a Supabase client with the `ssr` package automatically configures it toAdd the code below to your `src/hooks.server.ts` to initialize the client on the server:-```ts src/hooks.server.ts+<$CodeTabs>++```ts name=src/hooks.server.ts// src/hooks.server.tsimport { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public'import { createServerClient } from '@supabase/ssr'@@ -115,11 +121,15 @@ export const handle: Handle = async ({ event, resolve }) => {}```+</$CodeTabs>+<$Partial path="get_session_warning.mdx" />If you are using TypeScript the compiler might complain about `event.locals.supabase` and `event.locals.safeGetSession`, this can be fixed by updating your `src/app.d.ts` with the content below:-```ts src/app.d.ts+<$CodeTabs>++```ts name=src/app.d.ts// src/app.d.tsimport { SupabaseClient, Session } from '@supabase/supabase-js'@@ -140,9 +150,13 @@ declare global {}```+</$CodeTabs>+Create a new `src/routes/+layout.server.ts` file to handle the session on the server-side.-```ts src/routes/+layout.server.ts+<$CodeTabs>++```ts name=src/routes/+layout.server.ts// src/routes/+layout.server.tsimport type { LayoutServerLoad } from './$types'@@ -157,6 +171,8 @@ export const load: LayoutServerLoad = async ({ locals: { safeGetSession }, cooki}```+</$CodeTabs>+<Admonition type="tip">Start your dev server (`npm run dev`) in order to generate the `./$types` files we are referencing in our project.@@ -165,7 +181,9 @@ Start your dev server (`npm run dev`) in order to generate the `./$types` filesCreate a new `src/routes/+layout.ts` file to handle the session and the `supabase` object on the client-side.-```ts src/routes/+layout.ts+<$CodeTabs>++```ts name=src/routes/+layout.ts// src/routes/+layout.tsimport { createBrowserClient, createServerClient, isBrowser } from '@supabase/ssr'import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public'@@ -204,9 +222,13 @@ export const load: LayoutLoad = async ({ fetch, data, depends }) => {}```+</$CodeTabs>+Update your `src/routes/+layout.svelte`:-```svelte src/routes/+layout.svelte+<$CodeTabs>++```svelte name=src/routes/+layout.svelte<!-- src/routes/+layout.svelte --><script lang="ts">import '../styles.css'@@ -238,11 +260,15 @@ Update your `src/routes/+layout.svelte`:</div>```+</$CodeTabs>+## Set up a login pageCreate a magic link login/signup page for your application:-```svelte src/routes/+page.svelte+<$CodeTabs>++```svelte name=src/routes/+page.svelte<!-- src/routes/+page.svelte --><script lang="ts">import { enhance } from '$app/forms'@@ -299,9 +325,13 @@ Create a magic link login/signup page for your application:</form>```+</$CodeTabs>+Create a `src/routes/+page.server.ts` file that will handle our magic link form when submitted.-```ts src/routes/+page.server.ts+<$CodeTabs>++```ts name=src/routes/+page.server.ts// src/routes/+page.server.tsimport { fail, redirect } from '@sveltejs/kit'import type { Actions, PageServerLoad } from './$types'@@ -350,6 +380,8 @@ export const actions: Actions = {}```+</$CodeTabs>+### Email templateChange the email template to support a server-side authentication flow.@@ -377,7 +409,9 @@ In the following code snippet, we perform the following steps:- Exchange this `token_hash` for a session, which we store in storage (in this case, cookies).- Finally, the user is redirected to the `account` page or the `error` page.-```ts src/routes/auth/confirm/+server.ts+<$CodeTabs>++```ts name=src/routes/auth/confirm/+server.ts// src/routes/auth/confirm/+server.tsimport type { EmailOtpType } from '@supabase/supabase-js'import { redirect } from '@sveltejs/kit'@@ -412,20 +446,28 @@ export const GET: RequestHandler = async ({ url, locals: { supabase } }) => {}```+</$CodeTabs>+### Authentication error pageIf there is an error with confirming the token you will be redirect to this error page.-```svelte src/routes/auth/error/+page.svelte+<$CodeTabs>++```svelte name=src/routes/auth/error/+page.svelte<p>Login error</p>```+</$CodeTabs>+### Account pageAfter a user is signed in, they need to be able to edit their profile details and manage their account.Create a new `src/routes/account/+page.svelte` file with the content below.-```svelte src/routes/account/+page.svelte+<$CodeTabs>++```svelte name=src/routes/account/+page.svelte<!-- src/routes/account/+page.svelte --><script lang="ts">import { enhance } from '$app/forms';@@ -506,6 +548,8 @@ Create a new `src/routes/account/+page.svelte` file with the content below.</div>```+</$CodeTabs>+Now create the associated `src/routes/account/+page.server.ts` file that will handle loading our data from the server through the `load` functionand handle all our form actions through the `actions` object.@@ -594,7 +638,9 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for maLet's create an avatar for the user so that they can upload a profile photo. We can start by creating a new component called `Avatar.svelte` in the `src/routes/account` directory:-```svelte src/routes/account/Avatar.svelte+<$CodeTabs>++```svelte name=src/routes/account/Avatar.svelte<!-- src/routes/account/Avatar.svelte --><script lang="ts">import type { SupabaseClient } from '@supabase/supabase-js'@@ -691,11 +737,15 @@ Let's create an avatar for the user so that they can upload a profile photo. We</div>```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page:-```svelte src/routes/account/+page.svelte+<$CodeTabs>++```svelte name=src/routes/account/+page.svelte<!-- src/routes/account/+page.svelte --><script lang="ts">// Import the new component@@ -725,4 +775,6 @@ And then we can add the widget to the Account page:</div>```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx b/apps/docs/content/guides/getting-started/tutorials/with-swift.mdxindex 45d5e3ba52b..cb41c4408c4 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx@@ -32,7 +32,9 @@ You need the API URL and the `anon` key that you copied [earlier](#get-the-api-kThese variables will be exposed on the application, and that's completely fine since you have[Row Level Security](/docs/guides/auth#row-level-security) enabled on your database.-```swift Supabase.swift+<$CodeTabs>++```swift name=Supabase.swiftimport Foundationimport Supabase@@ -42,12 +44,16 @@ let supabase = SupabaseClient()```+</$CodeTabs>+### Set up a login viewSet up a SwiftUI view to manage logins and sign ups.Users should be able to sign in using a magic link.-```swift AuthView.swift+<$CodeTabs>++```swift name=AuthView.swiftimport SwiftUIimport Supabase@@ -116,6 +122,8 @@ struct AuthView: View {}```+</$CodeTabs>+<Admonition type="note">The example uses a custom `redirectTo` URL. For this to work, add a custom redirect URL to Supabase and a custom URL scheme to your SwiftUI application. Follow the guide on [implementing deep link handling](/docs/guides/auth/native-mobile-deep-linking?platform=swift).@@ -128,7 +136,9 @@ After a user is signed in, you can allow them to edit their profile details andCreate a new view for that called `ProfileView.swift`.-```swift ProfileView.swift+<$CodeTabs>++```swift name=ProfileView.swiftimport SwiftUIstruct ProfileView: View {@@ -227,11 +237,15 @@ struct ProfileView: View {}```+</$CodeTabs>+### ModelsIn `ProfileView.swift`, you used 2 model types for deserializing the response and serializing the request to Supabase. Add those in a new `Models.swift` file.-```swift Models.swift+<$CodeTabs>++```swift name=Models.swiftstruct Profile: Decodable {let username: String?let fullName: String?@@ -257,13 +271,17 @@ struct UpdateProfileParams: Encodable {}```+</$CodeTabs>+### Launch!Now that you've created all the views, add an entry point for the application. This will verify if the user has a valid session and route them to the authenticated or non-authenticated state.Add a new `AppView.swift` file.-```swift AppView.swift+<$CodeTabs>++```swift name=AppView.swiftimport SwiftUIstruct AppView: View {@@ -288,6 +306,8 @@ struct AppView: View {}```+</$CodeTabs>+Update the entry point to the newly created `AppView`. Run in Xcode to launch your application in the simulator.## Bonus: Profile photos@@ -302,7 +322,9 @@ photos and videos.Let's add support for the user to pick an image from the library and upload it.Start by creating a new type to hold the picked avatar image:-```swift AvatarImage.swift+<$CodeTabs>++```swift name=AvatarImage.swiftimport SwiftUIstruct AvatarImage: Transferable, Equatable {@@ -336,11 +358,15 @@ enum TransferError: Error {}```+</$CodeTabs>+{/* supa-mdx-lint-disable-next-line Rule001HeadingCase */}#### Add `PhotosPicker` to profile page-```swift ProfileView.swift+<$CodeTabs>++```swift name=ProfileView.swift+ import PhotosUI+ import Storage+ import Supabase@@ -510,9 +536,13 @@ struct ProfileView: View {}```+</$CodeTabs>+Finally, update your Models.-```swift Models.swift+<$CodeTabs>++```swift name=Models.swiftstruct Profile: Codable {let username: String?let fullName: String?@@ -528,6 +558,8 @@ struct Profile: Codable {}```+</$CodeTabs>+You no longer need the `UpdateProfileParams` struct, as you can now reuse the `Profile` struct for both request and response calls.At this stage you have a fully functional application!diff --git a/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx b/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdxindex 55fd2dff662..f5226885807 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx@@ -43,15 +43,21 @@ npm install @supabase/supabase-jsAnd finally we want to save the environment variables in a `.env`.All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).-```bash .env+<$CodeTabs>++```bash name=.envVITE_SUPABASE_URL=YOUR_SUPABASE_URLVITE_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```+</$CodeTabs>+With the API credentials in place, create an `src/supabase.js` helper file to initialize the Supabase client. These variables are exposedon the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.-```js src/supabase.js+<$CodeTabs>++```js name=src/supabase.jsimport { createClient } from '@supabase/supabase-js'const supabaseUrl = import.meta.env.VITE_SUPABASE_URL@@ -60,13 +66,17 @@ const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEYexport const supabase = createClient(supabaseUrl, supabaseAnonKey)```+</$CodeTabs>+Optionally, update [src/style.css](https://raw.githubusercontent.com/supabase/supabase/master/examples/user-management/vue3-user-management/src/style.css) to style the app.### Set up a login componentSet up an `src/components/Auth.vue` component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.-```vue /src/components/Auth.vue+<$CodeTabs>++```vue name=/src/components/Auth.vue<script setup>import { ref } from 'vue'import { supabase } from '../supabase'@@ -113,12 +123,16 @@ const handleLogin = async () => {</template>```+</$CodeTabs>+### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.Create a new `src/components/Account.vue` component to handle this.-```vue src/components/Account.vue+<$CodeTabs>++```vue name=src/components/Account.vue<script setup>import { supabase } from '../supabase'import { onMounted, ref, toRefs } from 'vue'@@ -227,11 +241,15 @@ async function signOut() {</template>```+</$CodeTabs>+### Launch!Now that we have all the components in place, let's update `App.vue`:-```vue src/App.vue+<$CodeTabs>++```vue name=src/App.vue<script setup>import { onMounted, ref } from 'vue'import Account from './components/Account.vue'@@ -259,6 +277,8 @@ onMounted(() => {</template>```+</$CodeTabs>+Once that's done, run this in a terminal window:```bash@@ -277,7 +297,9 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for maCreate a new `src/components/Avatar.vue` component that allows users to upload profile photos:-```vue src/components/Avatar.vue+<$CodeTabs>++```vue name=src/components/Avatar.vue<script setup>import { ref, toRefs, watchEffect } from 'vue'import { supabase } from '../supabase'@@ -357,11 +379,15 @@ watchEffect(() => {</template>```+</$CodeTabs>+### Add the new widgetAnd then we can add the widget to the Account page in `src/components/Account.vue`:-```vue src/components/Account.vue+<$CodeTabs>++```vue name=src/components/Account.vue<script>// Import the new componentimport Avatar from './Avatar.vue'@@ -380,4 +406,6 @@ const avatar_url = ref('')</template>```+</$CodeTabs>+At this stage you have a fully functional application!diff --git a/apps/docs/features/directives/CodeSample.client.tsx b/apps/docs/features/directives/CodeSample.client.tsxindex b0a566852a9..10c850162f9 100644--- a/apps/docs/features/directives/CodeSample.client.tsx+++ b/apps/docs/features/directives/CodeSample.client.tsx@@ -69,7 +69,7 @@ function SingleSource({ children, source }: PropsWithChildren<{ source: string |href={source.toString()}target="_blank"rel="noopener noreferrer"- className="block mb-4 text-right no-underline text-foreground-lighter text-sm"+ className="block -mt-5 mb-4 text-right no-underline text-foreground-lighter text-sm">View source</Link>diff --git a/apps/docs/features/directives/CodeTabs.test.ts b/apps/docs/features/directives/CodeTabs.test.tsindex c6382e01efc..be0a45bb2a4 100644--- a/apps/docs/features/directives/CodeTabs.test.ts+++ b/apps/docs/features/directives/CodeTabs.test.ts@@ -26,7 +26,7 @@ console.log('Hello, world!');expect(output).toEqual(`-<Tabs listClassNames="flex-nowrap overflow-x-auto">+<Tabs listClassNames="flex-nowrap overflow-x-auto -mb-6"><TabPanel id="a.js" label="a.js">\`\`\`js name=a.jsconsole.log('Hello, world!');diff --git a/apps/docs/features/directives/CodeTabs.ts b/apps/docs/features/directives/CodeTabs.tsindex b5f914a6a23..71ee9aa893c 100644--- a/apps/docs/features/directives/CodeTabs.ts+++ b/apps/docs/features/directives/CodeTabs.ts@@ -71,7 +71,7 @@ function rewriteNodes(tree: Root) {{type: 'mdxJsxAttribute',name: 'listClassNames',- value: 'flex-nowrap overflow-x-auto',+ value: 'flex-nowrap overflow-x-auto -mb-6',},],children: remappedChildren,diff --git a/apps/docs/styles/main.scss b/apps/docs/styles/main.scssindex 0353d0d4bf8..f8bf24e02d2 100644--- a/apps/docs/styles/main.scss+++ b/apps/docs/styles/main.scss@@ -361,3 +361,9 @@ th code {font-weight: var(--shiki-dark-font-weight) !important;text-decoration: var(--shiki-dark-text-decoration) !important;}++// Code blocks need margin applied when in content container++.prose :where(.shiki) {+ margin-block: 2rem;+}