Basic Example: Calling a Supabase Edge Function
This example shows how to call a Supabase Edge Function from your React Native app and display the result.
import { useEffect, useState } from 'react';
import { supabase } from '@/supabase';
import { Text, View } from 'react-native';
export default function EdgeFunctionExample() {
const [result, setResult] = useState('');
useEffect(() => {
async function callEdgeFunction() {
const { data, error } = await supabase.functions.invoke('hello-world', {
body: { name: 'ExpoBase' },
});
if (error) setResult('Error: ' + error.message);
else setResult(data.message);
}
callEdgeFunction();
}, []);
return (
<View style={{ padding: 24 }}>
<Text>Supabase Edge Function result:</Text>
<Text>{result}</Text>
</View>
);
}
Replace
'hello-world'
with your actual Edge Function name if needed.