Skip to content

Rights Center — React Native

The NativeRightCenter component provides a pre-built UI for DPDPA data subject rights — letting users access, correct, or delete their personal data and withdraw consent.

Create a dedicated screen for the Rights Center:

import React from 'react';
import { View } from 'react-native';
import Constants from 'expo-constants';
import { NativeRightCenter } from '@truconsent/consent-notice-react-native';
const extra = Constants.expoConfig?.extra ?? {};
export default function RightsCenterScreen() {
return (
<View style={{ flex: 1 }}>
<NativeRightCenter
userId="user-uuid"
apiKey={extra.truConsentApiKey}
organizationId={extra.truConsentOrganizationId}
apiUrl={extra.truConsentApiUrl}
assetId={extra.truConsentAssetId}
/>
</View>
);
}

Resolve the user ID before rendering the component:

import React, { useEffect, useState } from 'react';
import { View, ActivityIndicator, Text, TouchableOpacity } from 'react-native';
import Constants from 'expo-constants';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { NativeRightCenter } from '@truconsent/consent-notice-react-native';
import { useAuth } from '../hooks/useAuth';
const extra = Constants.expoConfig?.extra ?? {};
async function getOrCreateGuestId(): Promise<string> {
const stored = await AsyncStorage.getItem('guest_id');
if (stored) return stored;
const id = `guest_${Date.now()}_${Math.random().toString(36).slice(2)}`;
await AsyncStorage.setItem('guest_id', id);
return id;
}
export default function RightsCenterScreen() {
const { user } = useAuth();
const [userId, setUserId] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
async function resolveUserId() {
const id = user ? user.id : await getOrCreateGuestId();
setUserId(id);
setIsLoading(false);
}
resolveUserId();
}, [user]);
if (isLoading) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" />
</View>
);
}
if (!userId) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Unable to load Rights Center</Text>
<TouchableOpacity onPress={() => setIsLoading(true)}>
<Text>Retry</Text>
</TouchableOpacity>
</View>
);
}
return (
<View style={{ flex: 1 }}>
<NativeRightCenter
userId={userId}
apiKey={extra.truConsentApiKey}
organizationId={extra.truConsentOrganizationId}
apiUrl={extra.truConsentApiUrl}
assetId={extra.truConsentAssetId}
/>
</View>
);
}
// Expo Router — app/_layout.tsx
<Stack.Screen
name="rights-center"
component={RightsCenterScreen}
options={{ title: 'Privacy & Data Rights' }}
/>
// Navigate from settings
import { useRouter } from 'expo-router';
export default function SettingsScreen() {
const router = useRouter();
return (
<TouchableOpacity onPress={() => router.push('/rights-center')}>
<Text>Privacy & Data Rights</Text>
</TouchableOpacity>
);
}

NativeRightCenter is a named export; TruConsentModal is the default export:

import TruConsentModal from '@truconsent/consent-notice-react-native';
import { NativeRightCenter } from '@truconsent/consent-notice-react-native';
// Both at once
import TruConsentModal, { NativeRightCenter } from '@truconsent/consent-notice-react-native';
* Required
PropTypeDescription
userId *stringAuthenticated user ID. Must match the ID used when consent was recorded.
apiKey *stringAPI key from the platform dashboard.
organizationId *stringYour org ID — sent on every request.
apiUrl *stringSDK base URL: https://trukit-dev.truconsent.io
assetId *stringAsset UUID from the platform dashboard.
RightDPDPA reference
Access personal dataSection 11
Correction and erasureSection 12
Grievance redressalSection 13
Withdraw consentSection 6
Nominate a representativeSection 14