Miniapp APIs
Network and Phone
Use Nebula APIs to inspect network status, listen for connectivity changes, and place phone calls.
Get the current network type
import { getNetworkType } from '@nebula-rn/client';
const networkType = await getNetworkType();
console.log(networkType); // 'wifi' | 'cellular' | 'none' | 'unknown'Listen for network status changes
import { onNetworkStatusChange } from '@nebula-rn/client';
const unsubscribe = onNetworkStatusChange((status) => {
console.log('Connected:', status.isConnected);
console.log('Network type:', status.networkType);
});
// Stop listening
unsubscribe();Callback payload:
type NetworkStatusChangeResult = {
isConnected: boolean;
networkType: string;
};Example: network status indicator
import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';
import { getNetworkType, onNetworkStatusChange } from '@nebula-rn/client';
export default function NetworkIndicator() {
const [connected, setConnected] = useState(true);
const [type, setType] = useState('');
useEffect(() => {
getNetworkType().then(setType);
const unsubscribe = onNetworkStatusChange((status) => {
setConnected(status.isConnected);
setType(status.networkType);
});
return () => { unsubscribe(); };
}, []);
return (
<View>
<Text>
{connected ? `Connected (${type})` : 'No network connection'}
</Text>
</View>
);
}Place a phone call
import { makePhoneCall } from '@nebula-rn/client';
await makePhoneCall('10086');This opens the system dialer UI.