Files
supabase/examples/auth/quickstarts/react-native/App.tsx
Chris Chinchilla 587729411d docs: update React Native auth quickstart to remove getUser (#42196)
* Move old functions trouble shooting to new guides

* Replace getUser, update, and switch to codeblocks

* Revert "Move old functions trouble shooting to new guides"

This reverts commit 229c581172.

* Prettier

* Add env details

* Fixes
2026-01-28 00:16:28 +00:00

28 lines
652 B
TypeScript

import 'react-native-url-polyfill/auto'
import { useState, useEffect } from 'react'
import { supabase } from './lib/supabase'
import Auth from './components/Auth'
import { View, Text } from 'react-native'
import { User } from '@supabase/supabase-js'
export default function App() {
const [user, setUser] = useState<User | null>(null)
useEffect(() => {
supabase.auth.getUser().then(({ data: { user } }) => {
setUser(user)
})
supabase.auth.onAuthStateChange((_event, session) => {
setUser(session?.user ?? null)
})
}, [])
return (
<View>
<Auth />
{user && <Text>{user.id}</Text>}
</View>
)
}