Pluskode Client SDK for React Native - Wrapper around web client with React Native optimizations
npm install @pluskode/client-react-nativebash
npm install @pluskode/client-react-native
or
yarn add @pluskode/client-react-native
`
Usage
Same as Web Client SDK:
`typescript
import { PluskodeClient } from '@pluskode/client-react-native';
const client = new PluskodeClient({
baseURL: 'http://localhost:3000'
});
// All methods same as web client
const users = await client.get('/api/users');
client.subscribe('chat/room1', (data) => {
console.log('Message:', data);
});
`
React Native Example
`tsx
import React, { useEffect, useState } from 'react';
import { View, Text, FlatList } from 'react-native';
import { PluskodeClient } from '@pluskode/client-react-native';
const client = new PluskodeClient({
baseURL: 'http://localhost:3000'
});
export function UsersScreen() {
const [users, setUsers] = useState([]);
useEffect(() => {
client.get('/api/users')
.then(res => setUsers(res.data))
.catch(err => console.error(err));
}, []);
return (
data={users}
renderItem={({ item }) => {item.name} }
/>
);
}
``