Pluskode Client SDK for Expo - Optimized for Expo managed workflow with HTTPS/WSS support
npm install @pluskode/client-expobash
npm install @pluskode/client-expo
or
yarn add @pluskode/client-expo
`
Usage
$3
`typescript
import { PluskodeExpoClient } from '@pluskode/client-expo';
// Production (HTTPS required)
const client = new PluskodeExpoClient({
baseURL: 'https://api.example.com',
timeout: 30000,
retries: 3
});
// Development (localhost HTTP allowed)
const devClient = new PluskodeExpoClient({
baseURL: 'http://localhost:3000',
enforceSecure: false // Allow HTTP for localhost
});
`
$3
`typescript
// GET request
const users = await client.get('/api/users');
// POST request
const newUser = await client.post('/api/users', {
name: 'John',
email: 'john@example.com'
});
// PUT, PATCH, DELETE
await client.put('/api/users/123', { name: 'Jane' });
await client.patch('/api/users/123', { email: 'jane@example.com' });
await client.delete('/api/users/123');
`
$3
`typescript
// Subscribe to channel (uses WSS automatically)
const unsubscribe = client.subscribe('chat/room1', (data) => {
console.log('Message:', data);
});
// Send message
client.send('chat/room1', { text: 'Hello!' });
// Unsubscribe
unsubscribe();
`
$3
`typescript
const unsubscribe = client.subscribeSSE('/events/stream', (event) => {
console.log('Event:', event.event, 'Data:', event.data);
});
// Close
unsubscribe();
`
$3
`typescript
const user = await client.rpc(
'UserService',
'GetUser',
{ id: '123' }
);
`
$3
`typescript
// Subscribe
const unsubscribe = client.subscribeMQTT(
'sensors/temperature',
(topic, message, qos) => {
console.log(${topic}: ${message} (QoS: ${qos}));
},
{ qos: 1 }
);
// Publish
await client.publishMQTT(
'sensors/temperature',
'25.5',
{ qos: 1, retain: false }
);
`
Expo Example
`tsx
import React, { useEffect, useState } from 'react';
import { View, Text, FlatList } from 'react-native';
import { PluskodeExpoClient } from '@pluskode/client-expo';
const client = new PluskodeExpoClient({
baseURL: __DEV__ ? 'http://localhost:3000' : 'https://api.example.com'
});
export function UsersScreen() {
const [users, setUsers] = useState([]);
const [messages, setMessages] = useState([]);
useEffect(() => {
// Load users
client.get('/api/users')
.then(res => setUsers(res.data))
.catch(err => console.error(err));
// Subscribe to chat
const unsubscribe = client.subscribe('chat/room1', (data) => {
setMessages(prev => [...prev, data]);
});
return () => unsubscribe();
}, []);
return (
data={users}
renderItem={({ item }) => {item.name} }
/>
data={messages}
renderItem={({ item }) => {item.text} }
/>
);
}
`
Security & Compliance
$3
- Production: HTTPS/WSS is automatically enforced
- Development: HTTP/WS allowed only for localhost
- App Store/Play Store: Fully compliant
$3
1. App Store Requirements: iOS requires HTTPS for network requests
2. Play Store Requirements: Android requires secure connections
3. Security: Protects data in transit
4. Expo Managed Workflow: No native modules, pure JS/TS
Differences from React Native Client
| Feature | Expo Client | React Native Client |
|---------|-------------|---------------------|
| Native Modules | ❌ Not supported | ✅ Can use native modules |
| HTTPS Enforcement | ✅ Automatic | ⚠️ Manual |
| Managed Workflow | ✅ Optimized | ⚠️ May require custom native code |
| App Store Ready | ✅ Yes | ⚠️ Depends on setup |
Limitations
Since Expo managed workflow doesn't support custom native modules:
- gRPC: Uses gRPC-Web (via HTTP/HTTPS) instead of native gRPC
- MQTT: Uses MQTT over WebSocket instead of native MQTT
- Binary Streams: Uses WebSocket binary frames instead of raw TCP
These limitations are acceptable for most use cases and ensure App Store/Play Store compliance.
Requirements
- Expo SDK 45.0+
- React Native 0.60+
- TypeScript 5.0+ (optional)
License
MIT
---
Note: This client is optimized for Expo managed workflow. For bare React Native projects, use @pluskode/client-react-native` instead.