@spatial-os/web-sdk
v1.0.0
Published
Web SDK for Spatial OS - Planet-scale geospatial infrastructure
Maintainers
Readme
🌐 Spatial OS Web SDK
JavaScript/TypeScript SDK for Spatial OS - Build WebXR applications with persistent spatial anchors.
Features
- 📍 Spatial Anchors - Create and resolve world-locked content
- 🔄 WebXR Integration - Browser-based AR/VR support
- 👥 Real-time Presence - Track users in shared spaces via WebSocket
- 📦 Zero Dependencies - Lightweight and tree-shakeable
Installation
npm install @spatial-os/web
# or
yarn add @spatial-os/webCDN
<script src="https://unpkg.com/@spatial-os/web@latest/dist/spatial-os.min.js"></script>Quick Start
import { SpatialOS } from '@spatial-os/web';
const spatial = new SpatialOS({ apiKey: 'YOUR_API_KEY' });
// Login
await spatial.login('[email protected]', 'password');
// Create anchor
const anchor = await spatial.createAnchor({
spaceId: 'my-space',
anchorType: 'GPS',
position: { x: 0, y: 0, z: 0 },
rotation: { x: 0, y: 0, z: 0, w: 1 },
payload: 'my-content-id',
});
// Find nearby anchors
const nearby = await spatial.getNearbyAnchors(37.7749, -122.4194, 1.0);
// Real-time presence
spatial.presence.connect('my-space');
spatial.presence.on('userJoined', (user) => {
console.log('User joined:', user.id);
});TypeScript
Full TypeScript support included:
import { SpatialOS, Anchor, Space, Vector3 } from '@spatial-os/web';Browser Support
- Chrome 79+ (WebXR)
- Edge 79+
- Safari 15+ (AR Quick Look)
- Firefox (VR only)
Support
If you find Spatial OS useful, consider supporting the project:
License
MIT License - see LICENSE
