--- title: 'Use Supabase Auth with React Native' subtitle: 'Learn how to use Supabase Auth with React Native' breadcrumb: 'Auth Quickstarts' hideToc: true --- [Launch a new project](/dashboard) in the Supabase Dashboard. Your new database has a table for storing your users. You can see that this table is currently empty by running some SQL in the [SQL Editor](/dashboard/project/_/sql). ```sql name=SQL_EDITOR select * from auth.users; ```` Create a React app using the `create-expo-app` command. ```bash name=Terminal npx create-expo-app -t expo-template-blank-typescript my-app ``` Install `supabase-js` and the required dependencies. ```bash name=Terminal cd my-app && npx expo install @supabase/supabase-js @react-native-async-storage/async-storage @rneui/themed react-native-url-polyfill ``` Create a helper file `lib/supabase.ts` that exports a Supabase client using your Project URL and key. <$Partial path="api_settings_steps.mdx" /> ```ts name=lib/supabase.ts import { AppState, Platform } from 'react-native' import 'react-native-url-polyfill/auto' import AsyncStorage from '@react-native-async-storage/async-storage' import { createClient, processLock } from '@supabase/supabase-js' const supabaseUrl = YOUR_REACT_NATIVE_SUPABASE_URL const supabaseAnonKey = YOUR_REACT_NATIVE_SUPABASE_PUBLISHABLE_KEY export const supabase = createClient(supabaseUrl, supabaseAnonKey, { auth: { ...(Platform.OS !== "web" ? { storage: AsyncStorage } : {}), autoRefreshToken: true, persistSession: true, detectSessionInUrl: false, lock: processLock, }, }) // Tells Supabase Auth to continuously refresh the session automatically // if the app is in the foreground. When this is added, you will continue // to receive `onAuthStateChange` events with the `TOKEN_REFRESHED` or // `SIGNED_OUT` event if the user's session is terminated. This should // only be registered once. if (Platform.OS !== "web") { AppState.addEventListener('change', (state) => { if (state === 'active') { supabase.auth.startAutoRefresh() } else { supabase.auth.stopAutoRefresh() } }) } ``` Let's set up a React Native component to manage logins and sign ups. ```tsx name=components/Auth.tsx import React, { useState } from 'react' import { Alert, StyleSheet, View } from 'react-native' import { supabase } from '../lib/supabase' import { Button, Input } from '@rneui/themed' export default function Auth() { const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [loading, setLoading] = useState(false) async function signInWithEmail() { setLoading(true) const { error } = await supabase.auth.signInWithPassword({ email: email, password: password, }) if (error) Alert.alert(error.message) setLoading(false) } async function signUpWithEmail() { setLoading(true) const { data: { session }, error, } = await supabase.auth.signUp({ email: email, password: password, }) if (error) Alert.alert(error.message) if (!session) Alert.alert('Please check your inbox for email verification!') setLoading(false) } return ( setEmail(text)} value={email} placeholder="email@address.com" autoCapitalize={'none'} /> setPassword(text)} value={password} secureTextEntry={true} placeholder="Password" autoCapitalize={'none'} />