@spatial-os/react-native
v1.0.0
Published
React Native SDK for Spatial OS - Open-source spatial anchor infrastructure for AR/VR
Maintainers
Readme
📱 Spatial OS React Native SDK
React Native SDK for Spatial OS - Build cross-platform AR applications with persistent spatial anchors.
Features
- 📍 Spatial Anchors - Create and resolve world-locked content
- 🔄 ViroReact Integration - AR support with ViroReact
- 👥 Real-time Presence - Track users in shared spaces
- 🪝 React Hooks - Modern hooks-based API
Installation
npm install @spatial-os/react-native
# or
yarn add @spatial-os/react-nativeQuick Start
import { SpatialProvider, useAnchor, usePresence } from '@spatial-os/react-native';
function App() {
return (
<SpatialProvider apiKey="YOUR_API_KEY">
<MyARScene />
</SpatialProvider>
);
}
function MyARScene() {
const { anchors, createAnchor, loading } = useAnchor('my-space');
const { users, updatePosition } = usePresence('my-space');
const handleTap = async (position) => {
await createAnchor({
anchorType: 'GPS',
position,
payload: 'my-content',
});
};
return (
<ViroARScene onTap={handleTap}>
{anchors.map(anchor => (
<AnchorContent key={anchor.id} anchor={anchor} />
))}
</ViroARScene>
);
}Hooks
| Hook | Description |
|------|-------------|
| useSpatial() | Main client context |
| useAnchor(spaceId) | Anchor CRUD operations |
| usePresence(spaceId) | Real-time user presence |
| usePortal() | Cross-app navigation |
Requirements
- React Native 0.70+
- ViroReact (for AR features)
Support
If you find Spatial OS useful, consider supporting the project:
License
MIT License - see LICENSE
