# WebSpatial > WebSpatial is a set of spatial APIs and ready-to-use SDK that extend the standard 2D Web ecosystem to support spatial computing across platforms. It enables the entire HTML/CSS-based Web world to step into the spatial era, gaining spatial power on par with native apps (like visionOS apps) while keeping the advantages they already have. This file merges the latest English WebSpatial documentation into a single Markdown context. It excludes legacy 1.0.x docs and localized copies. For the lighter linked index, use llms.txt. Linked index: https://webspatial.dev/llms.txt ## Contents - [Getting Started](https://webspatial.dev/docs/introduction/getting-started.md): Understand what WebSpatial adds to the Web, how the SDK works, and how to integrate it into a React project. - [Concepts overview](https://webspatial.dev/docs/concepts.md): Core concepts behind WebSpatial, spatial computing, scenes, interactions, and 2D + 3D composition. - [Spatial Computing](https://webspatial.dev/docs/concepts/spatial-computing.md): Learn how spatial computing differs from traditional XR, including spatial apps, runtimes, and unified rendering. - [WebSpatial App](https://webspatial.dev/docs/concepts/webspatial-app.md): See how a standard Web App becomes a WebSpatial App, including the roles of the runtime and packaged app. - [Spatial Scenes](https://webspatial.dev/docs/concepts/spatial-scenes.md): Understand Spatial Scene containers, scene types, initialization, and how WebSpatial apps open multiple scenes. - [Spatialized HTML Elements](https://webspatial.dev/docs/concepts/spatialized-html-elements.md): Learn how ordinary HTML elements become spatialized surfaces with Z-axis layout, transforms, and spatial state. - [3D Content Containers](https://webspatial.dev/docs/concepts/3d-content-containers.md): Explore the 2D containing 3D model, static and dynamic 3D containers, and the local 3D spaces they create. - [Natural Interactions](https://webspatial.dev/docs/concepts/natural-interactions.md): Understand gaze, pinch, touch, and the spatial events WebSpatial exposes for natural interaction. - [How-to overview](https://webspatial.dev/docs/how-to.md): Practical setup guides for PWA requirements, JSX runtime configuration, SSR, Xcode, and app-store workflows. - [How to meet the minimum PWA requirements](https://webspatial.dev/docs/how-to/minimal-pwa.md): Prepare the minimum manifest, icons, and installability requirements needed for WebSpatial and packaged app workflows. - [How to configure the JSX runtime in non-TypeScript projects](https://webspatial.dev/docs/how-to/non-ts.md): Configure the WebSpatial JSX runtime in JavaScript-based React projects without TypeScript support. - [How to configure the JSX runtime in Rspack-based projects](https://webspatial.dev/docs/how-to/rspack.md): Set up the WebSpatial JSX runtime in Rspack or Rsbuild projects through swc-loader configuration. - [How to enable WebSpatial in SSR-enabled projects](https://webspatial.dev/docs/how-to/ssr.md): Enable WebSpatial in SSR projects by wrapping the app with SSRProvider and preserving the client-runtime split. - [How to install Xcode and visionOS-related components](https://webspatial.dev/docs/how-to/xcode.md): Install Xcode, simulators, and visionOS platform components required to run Packaged WebSpatial Apps locally. - [How to test on visionOS devices and submit to the App Store](https://webspatial.dev/docs/how-to/app-store-connect.md): Test Packaged WebSpatial Apps on visionOS devices and submit builds through App Store Connect. - [API overview](https://webspatial.dev/docs/api.md): Reference docs for WebSpatial Builder and the WebSpatial React SDK. - [React SDK overview](https://webspatial.dev/docs/api/react-sdk.md): Reference docs for React components, CSS APIs, DOM APIs, events, JS APIs, and scene configuration. - [React SDK / React Components overview](https://webspatial.dev/docs/api/react-sdk/react-components.md): React components and JSX markers for rendering 3D and spatial content. - [React SDK / React Components / JSX Markers](https://webspatial.dev/docs/api/react-sdk/react-components/jsx-marker.md): Mark JSX elements so the WebSpatial SDK can turn them into spatialized HTML elements. - [React SDK / React Components / ``](https://webspatial.dev/docs/api/react-sdk/react-components/Model.md): Render a static 3D model inside a spatialized container using the Web-standard-inspired `` API. - [React SDK / React Components / ``](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md): Render dynamic 3D content inside a spatialized container with the unified-rendering engine API. - [React SDK / CSS API overview](https://webspatial.dev/docs/api/react-sdk/css-api.md): CSS properties for spatial layout, depth, transforms, and material surfaces. - [React SDK / CSS API / `back`](https://webspatial.dev/docs/api/react-sdk/css-api/back.md): Lift an HTML element along the Z axis and position it in front of the page plane. - [React SDK / CSS API / Spatial Transform](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md): Apply true 3D translation, rotation, and scale to spatialized HTML elements and 3D containers. - [React SDK / CSS API / `background-material`](https://webspatial.dev/docs/api/react-sdk/css-api/background-material.md): Give scene and element backplates a transparent or real-time translucent material background. - [React SDK / CSS API / `depth`](https://webspatial.dev/docs/api/react-sdk/css-api/depth.md): Set the depth of 3D container elements so they render with real thickness in space. - [React SDK / DOM API overview](https://webspatial.dev/docs/api/react-sdk/dom-api.md): DOM properties for depth, back offset, and runtime environment detection. - [React SDK / DOM API / `userAgent`](https://webspatial.dev/docs/api/react-sdk/dom-api/userAgent.md): Inspect the current device, operating system, and whether the app is running in WebSpatial mode. - [React SDK / DOM API / `offsetBack`](https://webspatial.dev/docs/api/react-sdk/dom-api/offsetBack.md): Read how far a spatialized HTML element has moved forward from its original 2D position. - [React SDK / DOM API / `clientDepth`](https://webspatial.dev/docs/api/react-sdk/dom-api/clientDepth.md): Read the current rendered depth of a 3D container element in pixels. - [React SDK / DOM API / `innerDepth`](https://webspatial.dev/docs/api/react-sdk/dom-api/innerDepth.md): Read the current depth of a volume Spatial Scene through the DOM interface. - [React SDK / Event API overview](https://webspatial.dev/docs/api/react-sdk/event-api.md): Spatial interaction events for tap, drag, magnify, and rotate gestures. - [React SDK / Event API / Spatial Tap](https://webspatial.dev/docs/api/react-sdk/event-api/spatial-tap.md): Handle completed tap interactions on spatialized elements and 3D content. - [React SDK / Event API / Spatial Drag](https://webspatial.dev/docs/api/react-sdk/event-api/spatial-drag.md): Handle spatial drag gestures, including their phases and position payload. - [React SDK / Event API / Spatial Magnify](https://webspatial.dev/docs/api/react-sdk/event-api/spatial-magnify.md): Handle two-handed magnify gestures and read the scale factor produced by the interaction. - [React SDK / Event API / Spatial Rotate](https://webspatial.dev/docs/api/react-sdk/event-api/spatial-rotate.md): Handle two-handed rotate gestures and read the rotation produced in 3D space. - [React SDK / JS API overview](https://webspatial.dev/docs/api/react-sdk/js-api.md): JavaScript APIs for scene setup, metrics, and coordinate conversion. - [React SDK / JS API / `initScene`](https://webspatial.dev/docs/api/react-sdk/js-api/initScene.md): Configure initialization options for a new Spatial Scene before it opens. - [React SDK / JS API / `useMetrics`](https://webspatial.dev/docs/api/react-sdk/js-api/useMetrics.md): Convert between 2D pixel units and real-world meter units inside WebSpatial layouts. - [React SDK / JS API / `convertCoordinate`](https://webspatial.dev/docs/api/react-sdk/js-api/convertCoordinate.md): Convert points between the local and global coordinate systems used by scenes and spatial content. - [React SDK / Manifest Options overview](https://webspatial.dev/docs/api/react-sdk/manifest-options.md): Manifest options for configuring the main scene of a WebSpatial app. - [React SDK / Manifest Options / `main_scene`](https://webspatial.dev/docs/api/react-sdk/manifest-options/main-scene.md): Configure the Start Scene from the Web App Manifest before any page code runs. - [React SDK / Scene Options overview](https://webspatial.dev/docs/api/react-sdk/scene-options.md): Scene configuration options for sizing, scaling, alignment, and window behavior. - [React SDK / Scene Options / `type`](https://webspatial.dev/docs/api/react-sdk/scene-options/type.md): Choose whether a new Spatial Scene behaves like a window or a volume. - [React SDK / Scene Options / `defaultSize`](https://webspatial.dev/docs/api/react-sdk/scene-options/defaultSize.md): Set the initial width, height, and depth a Spatial Scene requests when it is created. - [React SDK / Scene Options / `resizability`](https://webspatial.dev/docs/api/react-sdk/scene-options/resizability.md): Limit how far users can resize a Spatial Scene after it opens. - [React SDK / Scene Options / `worldScaling`](https://webspatial.dev/docs/api/react-sdk/scene-options/worldScaling.md): Control whether a Spatial Scene keeps a constant apparent size or scales with distance. - [React SDK / Scene Options / `worldAlignment`](https://webspatial.dev/docs/api/react-sdk/scene-options/worldAlignment.md): Control whether a Spatial Scene stays upright, faces the user, or behaves more like a real object. - [React SDK / Scene Options / `baseplateVisibility`](https://webspatial.dev/docs/api/react-sdk/scene-options/baseplateVisibility.md): Show or hide the baseplate under a volume Spatial Scene. - [Builder overview](https://webspatial.dev/docs/api/builder.md): Command reference for previewing, building, and publishing packaged WebSpatial apps. - [Builder / `webspatial-builder run`](https://webspatial.dev/docs/api/builder/run.md): Launch a Packaged WebSpatial App in the simulator for local preview and debugging. - [Builder / `webspatial-builder build`](https://webspatial.dev/docs/api/builder/build.md): Build a Packaged WebSpatial App that can be installed on test devices or prepared for release workflows. - [Builder / `webspatial-builder publish`](https://webspatial.dev/docs/api/builder/publish.md): Upload a built Packaged WebSpatial App to App Store Connect for TestFlight or App Store submission. ## Introduction ### Getting Started Source: https://webspatial.dev/docs/introduction/getting-started.md Understand what WebSpatial adds to the Web, how the SDK works, and how to integrate it into a React project. ## Overview WebSpatial is a set of [minimal extensions to HTML/CSS/DOM APIs](https://tpac2025.webspatial.dev/) plus a [polyfill](https://www.w3.org/2001/tag/doc/polyfills/)-style open-source [SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk). It brings [spatialized UI capabilities](https://webspatial.dev/docs/introduction/getting-started.md#features) equivalent to [native spatial apps](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app) and a [2D containing 3D](https://webspatial.dev/docs/introduction/getting-started.md#philosophy) developer experience into Web standards and mainstream Web frameworks. This allows HTML content on [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md) platforms to break free from the screen, enter real space, gain real volume, support natural spatial interactions and flexible 3D programming, while preserving the Web's original [cross-platform nature](https://webspatial.dev/docs/introduction/getting-started.md#philosophy), mental model, and [development workflow](https://webspatial.dev/docs/introduction/getting-started.md#preview). The goal is to let the mainstream Web ecosystem and Web developers move seamlessly into the era of [spatial computing and multimodal AI](https://tpac2025.webspatial.dev/). ## Features ### WebSpatial API 1. **Spatial scenes**: The [start page](https://webspatial.dev/docs/concepts/spatial-scenes.md#start-scene) of a Web App (PWA), and every page of the same app [opened in a new window](https://webspatial.dev/docs/concepts/spatial-scenes.md#new-scenes), becomes a [spatial scene container](https://webspatial.dev/docs/concepts/spatial-scenes.md) integrated with the surrounding space. Different [initialization settings](https://webspatial.dev/docs/concepts/spatial-scenes.md#scene-initialization) can be applied to these containers. 2. **Material backplates**: For webpages using the [window scene type](https://webspatial.dev/docs/concepts/spatial-scenes.md#scene-type), the [background panel](https://webspatial.dev/docs/api/react-sdk/css-api/background-material.md) can use a native-feeling translucent material rendered dynamically based on viewpoint and environment, or it can be made fully transparent with no visible border so that elements appear to float separately in space. 3. **Volumetric windows**: A webpage window can change its [behavior in space](https://webspatial.dev/docs/concepts/spatial-computing.md) from serving 2D GUI needs first to [simulating a real-world object, so the window behaves like a "box"](https://webspatial.dev/docs/concepts/spatial-scenes.md#scene-type) with real volume and [depth](https://webspatial.dev/docs/api/react-sdk/dom-api/innerDepth.md). 4. **Spatialized HTML elements**: HTML elements can be "lifted" into the 3D space in front of the page plane while still participating in the CSS layout system. These [spatialized](https://webspatial.dev/docs/concepts/spatialized-html-elements.md) HTML elements keep their original state and APIs [on the X and Y axes](https://webspatial.dev/docs/concepts/spatialized-html-elements.md), while also becoming 2D planes floating in a spatial scene. They can have [material backplates](https://webspatial.dev/docs/api/react-sdk/css-api/background-material.md), be [laid out and positioned](https://webspatial.dev/docs/api/react-sdk/css-api/back.md) along the Z axis with CSS, receive 3D [transformations](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md) such as rotation, and expose [related state](https://webspatial.dev/docs/concepts/spatialized-html-elements.md) through DOM APIs. 5. **Material backgrounds**: The background of an HTML element can use a [real-time rendered translucent material](https://webspatial.dev/docs/api/react-sdk/css-api/background-material.md), instead of being limited to fixed colors. 6. **3D container elements**: Two new kinds of 3D HTML elements act as containers for 3D content with real volume. These 3D container elements still participate in the CSS layout system [as 2D planes](https://webspatial.dev/docs/concepts/spatialized-html-elements.md), support Z-axis [layout](https://webspatial.dev/docs/api/react-sdk/css-api/back.md) and [transforms](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md), and also create a local space in front of the 2D plane based on a [3D development paradigm](https://webspatial.dev/docs/concepts/3d-content-containers.md). Real volumetric 3D content can be rendered there so it fits into the 2D layout system and the [rendering model of 2D GUI frameworks](https://react.dev/learn/thinking-in-react), enabling a [2D containing 3D development paradigm](https://webspatial.dev/docs/introduction/getting-started.md#philosophy). 7. **Static 3D container elements**: The 3D content inside a container can be rendered from [prebuilt 3D model asset files](https://webspatial.dev/docs/api/react-sdk/react-components/Model.md). The API for this kind of 3D container element [is fully based on the Web standard model element](https://webspatial.dev/docs/api/react-sdk/react-components/Model.md). 8. **Dynamic 3D container elements**: The 3D content inside a container can be rendered dynamically through a [flexibly programmable, HTML-style 3D engine API](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api). 9. **HTML-style 3D engine APIs**: These APIs include [3D asset declarations](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api) such as models and materials, built-in capability modules, and ready-to-use [3D entities](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md) such as primitive shapes. These entities can be freely composed in a [3D coordinate system](https://webspatial.dev/docs/concepts/3d-content-containers.md#2d-containing-3d) using a tree structure and [Transform props](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md), enabling arbitrary 3D scenes and animations. 10. **2D attachment entities**: [2D HTML content can be attached to plane-shaped 3D entities](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md), so fully functional 2D content can also be embedded inside 3D content. 11. **Spatial interactions**: New [spatial interaction events](https://webspatial.dev/docs/concepts/natural-interactions.md#spatial-interactions) such as tap, drag, and rotate can be triggered on the 2D planes corresponding to spatialized HTML elements and on 3D content inside 3D container elements (on 3D mesh surfaces or bounding boxes), providing interaction information in 3D space such as positions in a 3D coordinate system. 12. **Mixed 2D + 3D content**: 2D content based on the CSS layout system and dynamic 3D container content based on the 3D engine can be combined through APIs such as [coordinate conversion and unit conversion](https://webspatial.dev/docs/concepts/3d-content-containers.md#2d-containing-3d), enabling alignment, coupling, and other integration patterns. ### WebSpatial SDK 1. **Forward-looking pre-implementation**: Together with a [native runtime implementation](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime), the proposed HTML/DOM/CSS APIs are [polyfilled (or "prollyfilled")](https://www.w3.org/2001/tag/doc/polyfills/) within the JSX, refs, and CSS of React projects. This makes the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) available immediately, without waiting for browser engines on each platform to formally support these APIs. 2. **Cross-version compatibility**: The SDK shields developers from instability, changes, and platform differences while WebSpatial APIs enter Web standards (HTML/CSS/DOM). The APIs exposed by the SDK remain backward compatible, so older code keeps working. 3. **Cross-platform compatibility**: On platforms that support [spatial computing and unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md), platform differences are hidden as much as possible so apps get unified spatial app concepts and spatialized UI features. On platforms that do not support spatial computing and unified rendering, the SDK will automatically ignore WebSpatial APIs, skip loading the full SDK implementation, and avoid affecting the behavior or performance of webpages in ordinary browsers on desktop computers, phones, and other screen-based devices. 4. **Custom cross-platform logic**: The SDK provides feature detection and [runtime detection](https://webspatial.dev/docs/api/react-sdk/dom-api/userAgent.md), so developers can add custom cross-platform handling for the small number of JS API / DOM API calls that can't be ignored automatically, and enable custom enhancements and platform-specific features on spatial computing platforms. 5. **App packaging**: A PWA can be packaged as a [native app bundle with its own WebSpatial Runtime and no external dependency](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app), such as a visionOS app. Like a native app, it can be installed on simulators or real devices for [preview and debugging](https://webspatial.dev/docs/introduction/getting-started.md#preview), and [submitted to app stores such as the visionOS App Store](https://webspatial.dev/docs/introduction/getting-started.md#distribution). ## Philosophy 1. WebSpatial adopts a new ["2D containing 3D"](https://webspatial.dev/docs/concepts/3d-content-containers.md#2d-containing-3d) development paradigm. It is built on the 2D Web ecosystem and HTML/CSS APIs, continuing the 2D mental model and development style developers already know. It only adds [Z-axis APIs for 2D elements](https://webspatial.dev/docs/concepts/spatialized-html-elements.md), plus APIs that [let a local 3D space behave like a 2D element](https://webspatial.dev/docs/concepts/3d-content-containers.md). The [3D development paradigm](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api) is confined inside local 3D spaces, and those local 3D renderings are integrated into the overall 2D rendering model. Developers can use 3D capabilities only where needed, instead of rebuilding an entire app as a 3D app and disconnecting from the mainstream 2D ecosystem. 2. WebSpatial only makes minimal extensions to HTML/CSS/DOM APIs. For [X/Y-axis-related functionality](https://webspatial.dev/docs/concepts/spatialized-html-elements.md), it continues to use existing Web standard APIs, which can be combined with the newly added [Z-axis-related APIs](https://webspatial.dev/docs/api/react-sdk/css-api/back.md). 3. Inside local 3D spaces, WebSpatial avoids doing [independent rendering](https://tpac2025.webspatial.dev/#webxr-not-enough) with low-level 3D graphics APIs as WebXR does. Instead, it uses a [declarative 3D engine API that combines ECS and HTML](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api), so spatial computing platforms can understand this 3D content and [render it together](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) with content from other apps in the same space. 4. WebSpatial avoids implementing all content for a [spatial app](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app) inside a single webpage the way a [WebXR session](https://developer.picoxr.com/document/web/introduce-webxr-standards/) does. Instead, it preserves standard Web development patterns such as multi-page sites, hyperlinks, and PWAs, and uses the [Web App Manifest](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app) and ["open links in a new window"](https://webspatial.dev/docs/concepts/spatial-scenes.md#new-scenes) to provide spatial app and [spatial container](https://webspatial.dev/docs/concepts/spatial-scenes.md) capabilities. 5. The [SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk) should keep its [simulated pre-implementation](https://www.w3.org/2001/tag/doc/polyfills/) of the proposed HTML/CSS/DOM APIs moderate, not overly complex or uncontrollable. For that reason, modifying [spatial styles/state](https://webspatial.dev/docs/concepts/spatialized-html-elements.md) and [listening to spatial events](https://webspatial.dev/docs/concepts/natural-interactions.md#spatial-interactions) is only supported in declarative code that follows the [Rules of React](https://react.dev/reference/rules), and [reading spatial styles/state (read-only)](https://webspatial.dev/docs/concepts/spatialized-html-elements.md) is only supported on objects obtained through [Hook APIs](https://react.dev/reference/react/hooks), such as [Refs](https://react.dev/learn/referencing-values-with-refs). Directly selecting DOM objects with imperative code is not supported for these operations. 6. The [SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk) should integrate into existing standard Web projects with as little cost as possible, in a way that is [close to one-click installation](https://webspatial.dev/docs/introduction/getting-started.md#installation), without changing the project's [original development, build, or deployment workflow](https://webspatial.dev/docs/introduction/getting-started.md#preview), and while ensuring that the site's existing behavior, performance, and debugging experience on desktop/mobile platforms and ordinary browsers are not affected. 7. With WebSpatial APIs and the SDK, building a new [spatial app](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app) should feel just like building a normal website. If developers want, the app can still be distributed as a standard website, preserving the Web's original cross-platform capability and its [URL-based usage model](https://tpac2025.webspatial.dev/#instant-apps). ## Supported Web Projects The open-source [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk) currently provides a [React SDK](https://webspatial.dev/docs/api/react-sdk.md). Any standard website project built with React should be able to enable the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) by integrating this SDK. The React SDK needs to be integrated into the [JSX Runtime](https://www.typescriptlang.org/docs/handbook/jsx.html). In React projects that use TypeScript, this requires only [one line of configuration](https://webspatial.dev/docs/introduction/getting-started.md#set-up-your-project) (a few web build tools need [extra configuration](https://webspatial.dev/docs/how-to/rspack.md)). In JavaScript projects, you [can only configure the JSX Runtime in the web build tool](https://webspatial.dev/docs/how-to/non-ts.md). The web build tools that have been tested and used most often so far are: - Vite - Next.js, Remix ([SSR is supported](https://webspatial.dev/docs/how-to/ssr.md)) - Rspack / Rsbuild / Webpack :::caution[Current limitation] The latest version of WebSpatial SDK currently has a bug that temporarily prevents support for styled-components. ::: ## Supported Platforms The [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md) platforms currently supported are: - ✅ [visionOS](https://developer.apple.com/visionos/) (for example, Vision Pro devices): with WebSpatial SDK, a website can be packaged as a [hybrid app](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app) that includes the full [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime), submitted to the App Store, and run with native spatial behavior - ✅ [PICO OS 6](https://developer.picoxr.com/document/discover/pico-os-6-overview/) (for example, [Project Swan](https://developer.picoxr.com/blog/pico-developer-special-event-2026/) devices): its OS-level [Web App Runtime](https://developer.picoxr.com/zh/document/web/web-app/) includes the [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime), so WebSpatial APIs on websites can work directly Spatial computing platforms currently working toward WebSpatial Runtime implementations are: - ⏳ [JSAR Runtime](https://jsar-project.github.io/runtime/) (for example, Rokid glasses) - ⏳ [IRIS OS](https://www.irisview.cn/) Spatial computing platforms planned for priority support, but currently waiting for stable native APIs, are: - ⏳ [Android XR](https://www.android.com/xr/) (for example, XREAL glasses) - ⏳ [Meta Horizon OS](https://developers.meta.com/horizon/) (for example, Meta Quest devices) ## Installation ### Step 1: Runtime SDK To enable the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) in a React project, install the React SDK and the underlying Core SDK provided by the [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk) project: ```bash npm2yarn npm install @webspatial/react-sdk @webspatial/core-sdk ``` ### Step 2 (Optional): Builder For spatial computing platforms that do not have a built-in [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime), the website must be packaged as a [native app that includes WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app). That requires these additional installation steps: :::tip[PICO OS 6 does not need packaging] The [Web App Runtime](https://developer.picoxr.com/document/web/web-app/) in [PICO OS 6](https://developer.picoxr.com/document/discover/pico-os-6-overview/) already includes WebSpatial Runtime and can make the WebSpatial APIs on a website work directly, so packaging is not required and none of the extra installation steps below are needed. ::: 1. Install the packaging tool ([WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder)) provided by the WebSpatial SDK project in the React project: ```bash npm2yarn npm install -D @webspatial/builder ``` 2. The WebSpatial Runtime implementation for each platform is provided as a separate npm package and must be installed independently. For example, to support visionOS, install: ```bash npm2yarn npm install -D @webspatial/platform-visionos ``` 3. To generate native app bundles, WebSpatial Builder must invoke the native development tools for the target platform. For visionOS, that means you must [install Xcode and visionOS-related components](https://webspatial.dev/docs/how-to/xcode.md). ## Set Up Your Project ### Step 1: JSX Runtime Before using the WebSpatial API, integrate the React SDK into the current React project's [JSX Runtime](https://www.typescriptlang.org/docs/handbook/jsx.html). For TypeScript React projects, you only need to configure the [`jsxImportSource`](https://www.typescriptlang.org/tsconfig/jsxImportSource.html) field in `tsconfig`: ```json title="tsconfig.json" {4} { "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "@webspatial/react-sdk", // ... ``` :::tip[Related setup guides] - For TS projects based on Rspack, you also need to [configure `swc-loader`](https://webspatial.dev/docs/how-to/rspack.md). - For JavaScript React projects, you need to [configure the JSX Runtime in the web build tool](https://webspatial.dev/docs/how-to/non-ts.md). - For projects with SSR enabled, you need to [add the Context required by the SDK](https://webspatial.dev/docs/how-to/ssr.md). ::: ### Step 2: Minimal PWA To provide the app information required by a spatial app and the [settings for the start window](https://webspatial.dev/docs/concepts/spatial-scenes.md#start-scene), the current site must [provide a Web App Manifest following the PWA standard](https://webspatial.dev/docs/how-to/minimal-pwa.md). :::tip[Sample files] [webspatial-icon-examples.zip](https://webspatial.dev/assets/guide/webspatial-icon-examples.zip) contains icon files and manifest file that already satisfy the PWA requirements. You just need to unzip it into a directory on your website that can be publicly accessed via URL, then embed the manifest file's URL in your HTML with ``. ::: :::tip[Already a PWA?] If the current site is already a PWA and can be installed as a PWA in Chrome, you can skip this step. ::: ## Boilerplate If you want to get started quickly, use the [`@webspatial/starter`](https://www.npmjs.com/package/@webspatial/starter) CLI. To scaffold a new WebSpatial project: ```bash title="Create a new WebSpatial project" npx @webspatial/starter create my-webspatial-app ``` To add WebSpatial AI resources to an existing web project in one command: ```bash title="Add WebSpatial AI resources to an existing project" npx @webspatial/starter ai ``` The `ai` command generates a project-local set of WebSpatial AI resources for the current web project, including the full documentation set, project guidance, and agent skills. These resources are designed to be embedded into developers' own web projects, so an agent can use them to understand the recommended WebSpatial workflow and help with setup, integration, and follow-up development tasks. ## Preview To preview and debug [WebSpatial effects](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api), first run the current Web project as a website just as you would in normal website development, and get an accessible URL. For example, using the [Dev Server](https://vite.dev/guide/#command-line-interface) from Vite: ```bash title="Start the local dev server" {1} vite dev # result: # -> Local: http://localhost:5173/ ``` ### Website Mode For spatial computing platforms with a [built-in WebSpatial Runtime](https://developer.picoxr.com/document/web/web-platform/) (for example, [PICO OS 6](https://developer.picoxr.com/document/discover/pico-os-6-overview/)): Just visit the current website URL in the PICO Browser on the [official simulator](https://developer.picoxr.com/document/spatial-toolkit/learn-about-pico-emulator/) or on a real PICO OS 6 device, then click the "Run as a standalone app" button in the address bar - the website will run as a [Web App with WebSpatial enabled](https://developer.picoxr.com/document/web/install-free/), and you can see the spatialized UI effects and volumetric 3D content produced by WebSpatial. :::tip[PICO OS 6 simulator networking] When previewing a local URL as a Web App on the PICO OS 6 simulator, the [URL is not required to use HTTPS](https://developer.picoxr.com/document/web/manifest/), and you need to use the default IP address `10.0.2.2`. For example, `http://10.0.2.2:5173/`. To access the Vite dev server via `10.0.2.2`, you need to [set `server: { host: true }` in Vite](https://vitejs.dev/config/server-options) so it allows IPs beyond `localhost` or `127.0.0.1`. ::: ### Packaged App Mode For spatial computing platforms without a built-in [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime) (for example, visionOS): You cannot preview and debug directly from a website URL. You need [WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder): Running Builder's [`run` command](https://webspatial.dev/docs/api/builder/run.md) gives you a "one-click preview" workflow. It automatically packages the current website as a [native app bundle that includes WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app), launches the official simulator (for example, the [visionOS simulator](https://webspatial.dev/docs/how-to/xcode.md)), transfers the app bundle into the simulator, installs it, and launches the app. ```bash title="Preview the app in the simulator" {1} webspatial-builder run --base="http://localhost:5173/" ``` :::info[`run` can use a temporary manifest] The `run` command allows the Web project to skip providing a Web App Manifest during the early development and debugging phase. In that case, Builder will provide temporary default [app information](https://webspatial.dev/docs/how-to/minimal-pwa.md) (`start_url` is `''`). ::: :::caution[Offline packaging slows iteration] If [`start_url` is incomplete and missing the domain](https://webspatial.dev/docs/api/builder/run.md#--manifest), and you do not [use `--base` to fill in the base part for `start_url`](https://webspatial.dev/docs/api/builder/run.md#--base), Builder will automatically package the website output into the native app bundle. During runtime, website files are loaded offline from local files inside the app bundle. During development and debugging, this mode means every code change requires rerunning Builder and waiting for packaging and installation to finish, which is inefficient. It is recommended to always provide the `--base` parameter during development and debugging. ::: To preview on a personal test device, run Builder's [`build` command](https://webspatial.dev/docs/api/builder/build.md) to generate an app bundle. For visionOS devices, you need to [obtain extra parameters from App Store Connect, register the test device in Xcode, and install the app](https://webspatial.dev/docs/how-to/app-store-connect.md). ## Debug Whether you run on a simulator or a test device, whether you access the website URL directly or package and install the website as a standalone app with WebSpatial Builder, you can remotely connect from DevTools in a browser on your local computer to the Web Runtime in the spatial computing environment for debugging. WebSpatial apps on visionOS are implemented on top of WebView. You can use Safari Web Inspector on macOS to remotely debug the state and Web code inside each WebView instance, just as you would when debugging webpages on iOS devices. See Apple's official documentation: [Inspecting iOS and iPadOS](https://developer.apple.com/documentation/safari-developer-tools/inspecting-ios) For Android-based spatial computing platforms such as PICO OS 6, you can use Chrome DevTools on a computer to remotely debug Web Apps with WebSpatial enabled. See Google's official documentation: [Remote debug Android devices](https://developer.chrome.com/docs/devtools/remote-debugging) ## Distribution There are two ways to distribute a Web App that includes WebSpatial: The first is to distribute it as a cross-platform website, spread it through URLs, and get traffic that way. On spatial computing platforms with a built-in WebSpatial Runtime, it can be [accessed on demand by URL](https://tpac2025.webspatial.dev/#instant-apps), used temporarily, or [installed onto a device as a PWA](https://developer.picoxr.com/document/web/installable/). :::tip[Web Apps on PICO OS 6] On [PICO OS 6](https://developer.picoxr.com/document/discover/pico-os-6-overview/) devices, a Web App can also [run independently](https://developer.picoxr.com/document/web/install-free/) outside the browser without being installed, and WebSpatial effects are enabled automatically. ::: The second is app-store distribution, where users discover the app in an app store, install it first, and then use it. Publishing to the visionOS App Store requires using the [`publish` command](https://webspatial.dev/docs/api/builder/publish.md) from [WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder) to generate the app bundle and upload it automatically to App Store Connect. This requires some [extra parameters and registration steps](https://webspatial.dev/docs/how-to/app-store-connect.md). The [PICO app store](https://developer.picoxr.com/document/distribute/) supports publishing a Web App directly by submitting a URL, without packaging and uploading it through WebSpatial Builder first. However, at the current stage, the PICO developer platform does not yet provide self-service Web App submission, so Web Apps must be published to the PICO app store through PICO's business partnership channels. ## Concepts ### Concepts overview Source: https://webspatial.dev/docs/concepts.md Core concepts behind WebSpatial, spatial computing, scenes, interactions, and 2D + 3D composition. #### Spatial Computing Source: https://webspatial.dev/docs/concepts/spatial-computing.md Learn how spatial computing differs from traditional XR, including spatial apps, runtimes, and unified rendering. Spatial computing is a new capability of computing devices and operating systems. It is a further evolution of traditional XR devices and XR operating systems, including [virtual reality, mixed reality, and augmented reality](https://developer.picoxr.com/document/web/introduce-xr/). Traditional XR operating systems continuously track objects in the surrounding space and the user, obtaining their 3D positions and poses. Software interfaces and virtual digital content can use this low-level data to dynamically integrate with the surrounding space, for example by staying fixed at a location in space while always facing the user, or by following the user's wrist and always appearing beside it. But traditional XR operating systems do not define exactly how software should integrate with space. Each XR app has to use the low-level data provided by the OS and design and implement its own behavior and effects. A spatial computing operating system (Spatial OS) implements this integration between software and space in a unified way. It performs substantial spatial computation inside the OS, exposes the resulting new capabilities, such as [spatialized UI](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) and mixed 2D/3D coexistence, to [spatial apps](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app), and performs [unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) for those apps. [visionOS](https://developer.apple.com/visionos/) and [PICO OS 6](https://developer.picoxr.com/document/discover/pico-os-6-overview/) are both Spatial OS platforms. ## Unified Rendering The purpose of unified rendering is to let a Spatial OS perform [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md) for different apps in a unified way, so the 2D and 3D content of multiple [spatial apps](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app) can coexist in the same space and share the same coordinate system and lighting environment, including effects such as spatial relationships, occlusion, and shadows. To make this possible, each spatial app cannot render its own content in isolation or implement interactions arbitrarily. Instead, apps must provide content through [OS-managed 2D/3D content containers called spatial scenes](https://webspatial.dev/docs/concepts/spatial-scenes.md), and implement that content through [APIs the operating system can understand](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api). This allows the OS to understand app content as much as possible, perform unified rendering, and give that content consistent space-aware behavior and natural interaction capabilities. ## Spatial Runtime To continuously perform [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md) and [unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering), a Spatial OS needs to run a single 3D space and a single 3D rendering engine. This is effectively a runtime responsible for all [spatial apps](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app): all spatial apps run in that 3D space and are rendered by that engine. When multiple spatial apps coexist, this 3D space is called Shared Space. When other spatial apps are hidden and the whole space is reserved for one app, it is called Full Space. In Shared Space, spatial apps cannot access private data such as eye tracking, hand movement, and spatial environment information by default. Apps can only access such data after the user authorizes Full Space mode and the app exclusively occupies the entire space, allowing it to perform custom spatial computation. ## Spatial App A spatial app is an app that runs in [Shared Space or Full Space](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime), is [rendered in a unified way](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) by the operating system, and automatically gains [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md) capabilities. Spatial apps adopt the ["2D containing 3D"](https://webspatial.dev/docs/concepts/3d-content-containers.md#2d-containing-3d) development paradigm. Existing 2D apps, such as [Web Apps](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app), can become spatial apps as long as they can use [new spatial computing APIs such as WebSpatial APIs](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api). Developers can add code where needed to let 2D content enter 3D space, add real volumetric 3D content mixed with 2D content, and make content support spatial interactions and integration with the surrounding space. If spatial computing APIs are not used, the UI of a 2D app is not automatically spatialized or turned into 3D content, and the app does not automatically become a spatial app. Apps built on OpenXR and low-level 3D graphics APIs, including WebXR content in webpages, are not spatial apps, because they need to render themselves independently and occupy the entire space exclusively. They cannot coexist with other apps in the same space and cannot reuse the full spatial computing capabilities of the Spatial OS. #### WebSpatial App Source: https://webspatial.dev/docs/concepts/webspatial-app.md See how a standard Web App becomes a WebSpatial App, including the roles of the runtime and packaged app. A [Web App](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app) that uses the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) becomes a spatial app when it runs as a standalone app on a [spatial computing platform](https://webspatial.dev/docs/concepts/spatial-computing.md) and enables spatial computing capabilities with the help of the [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime). This is called a WebSpatial App. A WebSpatial App is an enhancement of a standard Web App, and that enhancement is activated only under suitable conditions. If the same Web App runs on platforms that do not support spatial computing, such as browsers on desktop computers or phones, it is still a normal webpage or PWA with no spatial computing effects, and WebSpatial does not affect it. For the same Web App to run as a WebSpatial App and enable spatial computing capabilities, the operating system must support spatial computing and unified rendering, and the runtime environment must also include WebSpatial Runtime. Current browser UIs are designed for screen-based devices and for efficiently browsing multiple 2D webpages. They conflict with spatial app UI patterns such as transparent backgrounds and UI elements that float or protrude in space. Because of that, those browsers, such as Safari on visionOS and the default browser on PICO OS 6, cannot currently include WebSpatial Runtime and will run such a Web App as a normal webpage. If the same Web App runs independently outside the browser on PICO OS 6 through the [Web App Runtime](https://developer.picoxr.com/document/web/web-platform/), or is packaged with [WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder) as a [Packaged Hybrid App](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app) and run on visionOS, it gains a runtime environment with WebSpatial Runtime, becomes a WebSpatial App, and enables spatial computing capabilities. WebXR content can be "contained" inside a WebSpatial App, because a WebSpatial App is still a standard Web App composed of normal webpages. A webpage in the app can start a WebXR session through JS APIs, take over the entire space, and render WebXR content with low-level 3D graphics APIs such as WebGL or WebGPU. But that space is not [Full Space](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime), and it is not [unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering). Rendering is handled independently by the WebXR code itself. Once a WebXR session starts, the original webpages and spatialized UI of the WebSpatial App are hidden and are not shown at the same time. :::caution[Current limitation on visionOS] Because WKWebView on visionOS does not currently support WebXR, Packaged WebSpatial Apps on visionOS cannot start a WebXR session for now. ::: ## Web App Broadly speaking, any website that provides complete app functionality is a Web App. But a traditional website is just a set of webpages or URLs linked to one another. These pages or URLs run as separate tabs in a browser and have weak relationships with each other. There is no standardized way for a page to expose information about the entire Web App, such as the app name, app icon, or which URLs belong to the app. The [Web App Manifest](https://webspatial.dev/docs/how-to/minimal-pwa.md), which was added to Web standards as part of the PWA standard, lets webpages provide information about the Web App they belong to. This allows the Web App to run independently outside the browser, be installed like a native app, and gain more native-like experiences and capabilities. So in WebSpatial documentation, "Web App" specifically means PWA. A website [only needs to include a Web App Manifest to become a PWA](https://webspatial.dev/docs/how-to/minimal-pwa.md); other PWA technologies are not required. ## Web Runtime Web Runtime refers to a runtime that can run Web Apps, webpages, and Web code such as HTML/CSS/JS according to Web standards. This runtime is composed of the browser engine and other native implementations. Safari and WKWebView on visionOS are both Web Runtimes. A [Packaged WebSpatial App](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app) generated by [WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder) that includes [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime) renders webpages and all HTML/CSS/JS code through WKWebView, so these hybrid apps are also Web Runtimes. The [Web App Runtime](https://developer.picoxr.com/document/web/web-app/) on PICO OS 6, which includes [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime), is also a kind of Web Runtime and uses the [same Chromium core](https://developer.picoxr.com/document/web/web-platform/) as the PICO browser. In other words, WebSpatial Runtime is always built into a Web Runtime and is part of that Web Runtime. That is why a [WebSpatial App](https://webspatial.dev/docs/concepts/webspatial-app.md) retains the original capabilities of a [standard Web App](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app) and inherits the code and development model of a standard Web App. ## WebSpatial Runtime WebSpatial Runtime builds on top of a [Web Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#web-runtime) and additionally implements the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api). It exposes the operating system's [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) capabilities to [standard Web Apps](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app), so those apps are enhanced when running on such systems. Eventually, WebSpatial Runtime will be implemented entirely inside browser engines. But at the current stage, to make the proposed WebSpatial standards available immediately, the implementation combines browser engines and hybrid techniques, and must be used together with the [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk). Some spatial computing operating systems include WebSpatial Runtime, such as [PICO OS 6](https://developer.picoxr.com/document/web/web-app/). On those platforms, standard Web Apps that use WebSpatial SDK can run independently by URL and enable spatial computing directly. Some spatial computing operating systems do not include WebSpatial Runtime, such as visionOS. To enable spatial computing on those platforms, a standard Web App that uses WebSpatial SDK must be packaged with [WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder) as a [Packaged WebSpatial App](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app) that includes WebSpatial Runtime. The WebSpatial Runtime implementations for those specific platforms, which can be packaged into hybrid apps, are provided as separate npm packages. For example, WebSpatial SDK [provides `@webspatial/platform-visionos` for visionOS](https://webspatial.dev/docs/introduction/getting-started.md#step-2-optional-builder). ## Packaged WebSpatial App A Packaged WebSpatial App is a native [spatial app](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app) that includes both [WebSpatial Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-runtime) and [Web Runtime](https://webspatial.dev/docs/concepts/webspatial-app.md#web-runtime). It is effectively a native app shell that runs a [Web App](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app), behaving much like an installed PWA running independently. Based on the [Web App Manifest](https://webspatial.dev/docs/how-to/minimal-pwa.md), it loads the start page in its own standalone window and also supports opening more pages from the same Web App in additional windows. If the Web App uses the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) through the [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk), spatial computing is automatically enabled in this environment. Such an app can be [previewed](https://webspatial.dev/docs/introduction/getting-started.md#preview) and [debugged](https://webspatial.dev/docs/introduction/getting-started.md#debug) on the official simulator and test devices for the target spatial computing platform, such as visionOS, and can also be [submitted to app stores](https://webspatial.dev/docs/introduction/getting-started.md#distribution). The target spatial computing platform itself does not need to include WebSpatial Runtime, but the environment used for packaging the app must have the required WebSpatial Runtime prepared in advance. For visionOS, for example, the project must install [`@webspatial/platform-visionos`](https://webspatial.dev/docs/introduction/getting-started.md#step-2-optional-builder). To obtain a Packaged WebSpatial App, you first need a [website project integrated with WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#supported-web-projects), and you use a [Web Build Tool](https://webspatial.dev/docs/concepts/webspatial-app.md#web-build-tool) to compile it into website output files that can be deployed to a server. At that point, you can already package it directly with [WebSpatial Builder](https://webspatial.dev/docs/concepts/webspatial-app.md#webspatial-builder). Builder will automatically [copy the website output into the app bundle](https://webspatial.dev/docs/introduction/getting-started.md#packaged-app-mode), and at runtime the app will load HTML/CSS/JS and other Web files locally from the bundle instead of over the network. If you additionally [serve the output from the Web Build Tool as a website](https://webspatial.dev/docs/introduction/getting-started.md#preview) and get a URL that the simulator or spatial computing device can access, then [pass that URL to WebSpatial Builder](https://webspatial.dev/docs/api/builder/run.md#--base), you can generate an app bundle that does not include the website output itself, and the app will load HTML/CSS/JS and other Web files online during runtime. ## Web Build Tool A Web Build Tool refers to tools such as Vite, Rspack, and Webpack that compile and build source code based on Web frameworks into the HTML pages, CSS, JS, and other static Web files actually served by a Web server. Web frameworks such as Next.js include their own Web Build Tool. At the current stage, the [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk) needs [a Web framework (React) and a Web Build Tool](https://webspatial.dev/docs/introduction/getting-started.md#supported-web-projects) in order to let developers use the [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) in source code. ## WebSpatial Builder WebSpatial SDK provides a development tool called WebSpatial Builder (package name [`@webspatial/builder`](https://webspatial.dev/docs/introduction/getting-started.md#installation)) to simplify generating, [previewing](https://webspatial.dev/docs/introduction/getting-started.md#preview), and [distributing](https://webspatial.dev/docs/introduction/getting-started.md#distribution) a [Packaged WebSpatial App](https://webspatial.dev/docs/concepts/webspatial-app.md#packaged-webspatial-app). This tool provides three commands: - [`run`](https://webspatial.dev/docs/api/builder/run.md): preview in a simulator - [`build`](https://webspatial.dev/docs/api/builder/build.md): preview on a test device - [`publish`](https://webspatial.dev/docs/api/builder/publish.md): submit to an app store #### Spatial Scenes Source: https://webspatial.dev/docs/concepts/spatial-scenes.md Understand Spatial Scene containers, scene types, initialization, and how WebSpatial apps open multiple scenes. A Spatial Scene, also called a Spatial Container, is the most basic container that a spatial computing operating system provides for [spatial apps](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-app). It is used to enable [unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) and provide the [basic capabilities that integrate software with space](https://webspatial.dev/docs/concepts/spatial-computing.md). All content in a spatial app must be provided through this kind of container, just as app content in desktop operating systems is provided through windows. For a [WebSpatial App](https://webspatial.dev/docs/concepts/webspatial-app.md), each Spatial Scene is effectively a webpage loaded and run by URL inside an independent "window". A WebSpatial App is composed entirely of these "windows", and all content comes from the HTML/CSS/JS code running inside them. This kind of "window" does not include browser tabs, an address bar, or similar browser UI. The space is left to the webpage itself. It only provides a [minimal menu similar to a PWA window](https://web.dev/learn/pwa/app-design#standalone_experience), floating above the webpage content and collapsed by default, with essential Web App functions such as "copy current URL" and "open in browser". By default, it also includes navigation buttons such as "Back". If the `display` mode in the Web App Manifest is [set to `standalone`](https://developer.mozilla.org/docs/Web/Progressive_web_apps/Manifest/Reference/display), the navigation buttons are hidden and navigation relies entirely on UI inside the webpage. ## Scene Type Spatial Scenes currently have three types: The default is the `window` type. Its main content is a 2D plane floating in space. Users can drag to resize its width and height, subject to [initialization constraints](https://webspatial.dev/docs/api/react-sdk/scene-options/resizability.md), and can drag it to move it in space, subject to the spatial computing logic in the [Spatial Runtime](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime). During movement, it will also always [keep a constant size relative to the user's field of view](https://webspatial.dev/docs/api/react-sdk/scene-options/worldScaling.md), because this type of Spatial Scene primarily serves GUI needs and needs to keep content and text clear and readable. By default, webpage content is located on this 2D plane. The viewport size and window size exposed through existing Web APIs, such as `window.innerHeight`, are equal to the size of this plane. The height returned by `window.outerHeight` additionally includes the height of the PWA menu. The backplate of this 2D plane can be set to [fully transparent with no border](https://webspatial.dev/docs/api/react-sdk/css-api/background-material.md), making webpage content look as if it were floating separately in the air. It can also use a native-feeling translucent material, such as a frosted-glass effect on visionOS, rendered dynamically in real time based on viewpoint and environment. [Spatialized HTML elements](https://webspatial.dev/docs/concepts/spatialized-html-elements.md) can be "lifted" from this 2D plane into the 3D space in front of it, toward the user, and can receive Z-axis [layout](https://webspatial.dev/docs/api/react-sdk/css-api/back.md) and [transforms](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md). If the webpage adds [3D content container elements](https://webspatial.dev/docs/concepts/3d-content-containers.md), volumetric 3D content is also rendered in the space in front of this 2D plane. So a `window` Spatial Scene is not just a flat plane and is not limited to pure 2D content. It can also contain spatialized UI and volumetric 3D content. Spatial Scenes can also be set to the `volume` type. This type no longer prioritizes GUI needs and is instead used to simulate real-world objects. Accordingly, this kind of Spatial Scene has an additional depth dimension besides width and height. Depth can be set through [`defaultSize`](https://webspatial.dev/docs/api/react-sdk/scene-options/defaultSize.md) and read through [`innerDepth`](https://webspatial.dev/docs/api/react-sdk/dom-api/innerDepth.md). When users drag it to move it in space, its behavior is still constrained by the Spatial Runtime's spatial computing logic, but unlike the `window` type, it shows a distance-based scaling effect by default unless the [`worldScaling` property](https://webspatial.dev/docs/api/react-sdk/scene-options/worldScaling.md) is changed during initialization. Another default behavior is that it always faces the user, unless the [`worldAlignment` property](https://webspatial.dev/docs/api/react-sdk/scene-options/worldAlignment.md) is changed during initialization to make it behave more like a real object. Webpage content is still located on the back face of the `volume` by default, and the webpage size is equal to the size of that back face. Spatialized 2D HTML elements and volumetric content inside 3D container elements can all appear in the space in front of that back face, with the same capabilities and behavior as the `window` type. Both of these Spatial Scene types are effectively bounded local spaces inside the [entire 3D space (Shared Space or Full Space)](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime) run by the Spatial Runtime. A WebSpatial App can only show webpage content inside the bounds of these local spaces. Anything beyond them is clipped. The third Spatial Scene type is `stage`, which has no bounds and can only be created in [Full Space](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime) mode. WebSpatial SDK does not support this type yet. ## Scene Initialization Browser windows in desktop operating systems can use Web APIs to set size and even position in webpage code, and these properties can continue to be controlled and modified. The integration between a Spatial Scene and the surrounding space, and the associated spatial computing behavior, are managed uniformly by the operating system. So once these containers are created, their own properties, such as size and position, are not allowed to be modified by spatial app code. However, during the initialization phase before a container is created, spatial app code can provide custom initialization properties, such as the [`defaultSize`](https://webspatial.dev/docs/api/react-sdk/scene-options/defaultSize.md), [`resizability`](https://webspatial.dev/docs/api/react-sdk/scene-options/resizability.md), and [`worldScaling`](https://webspatial.dev/docs/api/react-sdk/scene-options/worldScaling.md) mentioned above, to influence the initial state of the Spatial Scene and its subsequent spatial computing behavior. In a WebSpatial App, the Spatial Scene type is also configured through custom initialization properties, using the [`type` property](https://webspatial.dev/docs/api/react-sdk/scene-options/type.md). ## Start Scene When a WebSpatial App starts, the first Spatial Scene is created automatically. This is called the Start Scene. The webpage URL loaded into it is determined by the [`start_url` field](https://webspatial.dev/docs/how-to/minimal-pwa.md) in the [Web App Manifest](https://webspatial.dev/docs/concepts/webspatial-app.md#web-app) by default. Before the Start Scene is created, no webpage code can run. So if you want to provide custom initialization properties for the Start Scene, they can only be [configured through the Web App Manifest](https://webspatial.dev/docs/api/react-sdk/manifest-options/main-scene.md). ## New Scenes A WebSpatial App can create more Spatial Scenes through the existing Web standard capability to open links in a new window, allowing more content to coexist and making fuller use of the surrounding space. For example: - `` - `` - `window.open(newSceneUrl);` - `window.open(newSceneUrl, "newSceneName");` The URLs of these links must belong to the current Web App, meaning they match the [`scope` in the Web App Manifest](https://developer.mozilla.org/docs/Web/Progressive_web_apps/Manifest/Reference/scope). Otherwise they are opened in a browser window as third-party URLs. Before these links are opened and the new Spatial Scene is created, the WebSpatial SDK can use the [`initScene` API to provide custom initialization properties for the new Spatial Scene, as long as the new scene has a `name`](https://webspatial.dev/docs/api/react-sdk/js-api/initScene.md). #### Spatialized HTML Elements Source: https://webspatial.dev/docs/concepts/spatialized-html-elements.md Learn how ordinary HTML elements become spatialized surfaces with Z-axis layout, transforms, and spatial state. Spatialized HTML elements are HTML elements that are not limited to the page plane and can enter the space in front of the webpage. Most existing 2D HTML elements in Web standards can be [marked as spatialized HTML elements](https://webspatial.dev/docs/api/react-sdk/react-components/jsx-marker.md#enable-xr) through the [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk). The [3D content container elements](https://webspatial.dev/docs/concepts/3d-content-containers.md) provided by WebSpatial SDK as React components are also spatialized HTML elements. The element itself is treated as a 2D plane and has the same characteristics and behavior as a spatialized 2D HTML element, while additionally rendering 3D content in the space in front of that 2D plane. All spatialized HTML elements are effectively 2D planes floating in the space of a [Spatial Scene](https://webspatial.dev/docs/concepts/spatial-scenes.md). Even after leaving the webpage plane, they still participate in the overall HTML/CSS layout system of the page and keep their original place in the page plane. The width and height of these 2D planes, and their positions on the X and Y axes, are entirely determined by the existing HTML/CSS layout system. In effect, they stay synchronized with the place they occupy in the webpage plane. :::note[Transform does not change layout bounds] [CSS Transform](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md) changes how spatialized HTML elements appear in position and size, but does not change their actual position and size in the layout system. ::: WebSpatial API only adds Z-axis-related CSS capabilities and DOM APIs for these spatialized HTML elements, allowing these 2D planes to be [laid out and positioned](https://webspatial.dev/docs/api/react-sdk/css-api/back.md) and [transformed](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md) along the Z axis, and allowing their current related state to be [read](https://webspatial.dev/docs/api/react-sdk/dom-api/offsetBack.md). :::caution[Current limitation] For spatialized HTML elements whose 2D planes rotate or otherwise change in space because of [CSS Transform](https://webspatial.dev/docs/api/react-sdk/css-api/transform.md), WebSpatial SDK does not currently support using [`getBoundingClientRect()`](https://developer.mozilla.org/docs/Web/API/Element/getBoundingClientRect) to obtain their projected bounds, and also does not yet support using `getBoundingClientCube()`, newly added in WebSpatial API, to obtain their 3D bounding-box range in space. ::: These new Z-axis CSS/DOM APIs can be combined with existing X/Y-axis CSS/DOM APIs from Web standards. Existing Web standard APIs such as `opacity`, `display: none`, and `visibility: hidden` continue to work on spatialized HTML elements. Like a `window` Spatial Scene, a spatialized 2D HTML element can give itself a [real-time rendered translucent material backplate](https://webspatial.dev/docs/api/react-sdk/css-api/background-material.md), which can be combined with `border-radius`, or keep the default fully transparent state with no backplate, effectively `background: none`. Because spatialized HTML elements are independent 2D planes in space, they are no longer affected by `z-index`. They will not be occluded by ordinary HTML elements, and can only be occluded by other spatialized HTML elements depending on parent-child nesting relationships and Z-axis positions. Inside a spatialized 2D HTML element, other 2D elements or 3D container elements [marked as spatialized HTML elements](https://webspatial.dev/docs/api/react-sdk/react-components/jsx-marker.md#enable-xr) can be used as children. Unless the child element is set to `position: fixed`, the child's Z-axis position is [relative to the nearest spatialized HTML element in the parent chain](https://webspatial.dev/docs/api/react-sdk/css-api/back.md). The rest of the content inside a spatialized 2D HTML element is still ordinary 2D HTML/CSS content, all located on the 2D plane corresponding to the nearest spatialized HTML element in the parent chain. All spatialized HTML elements support the new [spatial interaction events](https://webspatial.dev/docs/concepts/natural-interactions.md#spatial-interactions). The [local coordinate system](https://webspatial.dev/docs/concepts/3d-content-containers.md#2d-containing-3d) used in event results is the coordinate system of the 2D plane corresponding to the spatialized HTML element, with the origin at the top-left corner and the same point unit (`px`) used by the 2D layout system. For performance and complexity reasons, WebSpatial SDK only supports CSS updates in declarative code that follows the [Rules of React](https://react.dev/reference/rules), such as changing `className` or `style` in JSX. If you want to query the current state through DOM APIs, you need to use React's `useRef` to obtain the DOM object for the spatialized HTML element. Direct DOM queries through non-React approaches such as `querySelector` are not supported. WebSpatial SDK does not currently support adding CSS properties of spatialized HTML elements into CSS animations. Only JS-based animation approaches are supported. #### 3D Content Containers Source: https://webspatial.dev/docs/concepts/3d-content-containers.md Explore the 2D containing 3D model, static and dynamic 3D containers, and the local 3D spaces they create. Existing HTML elements can only display content in 2D planes. Even the WebGL-based `` element and the new `` element can only render 3D content inside a flat canvas. From the perspective of [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md), they are still part of 2D content. Although the WebXR API can render volumetric 3D content in 3D space with WebGL, that content [can only be displayed inside a WebXR session](https://webspatial.dev/docs/concepts/webspatial-app.md) and cannot participate in the HTML/CSS system as a 3D HTML element or be displayed directly in a Web App. The [WebSpatial API](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-api) adds two real 3D HTML elements on top of existing HTML standards. These elements are both [spatialized HTML elements](https://webspatial.dev/docs/concepts/spatialized-html-elements.md). They are used as floating 2D planes in space, continue to participate in the HTML/CSS layout system, and have the same capabilities and usage patterns as spatialized 2D HTML elements. In addition, they can render truly volumetric 3D content in the local space in front of their 2D plane using a [3D development paradigm](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api), support [unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering), and let 3D content [coexist and integrate with 2D content](https://webspatial.dev/docs/concepts/3d-content-containers.md#2d-containing-3d). In addition to using existing Web standards to determine the width and height of the 2D plane, 3D container elements can also use the new WebSpatial CSS property [`depth`](https://webspatial.dev/docs/api/react-sdk/css-api/depth.md) to set the depth of the local 3D space in front of the 2D plane, and can use the new DOM API [`clientDepth`](https://webspatial.dev/docs/api/react-sdk/dom-api/clientDepth.md) to query the current depth. The [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk) provides these two 3D container elements as React components. ## Static 3D Containers The first kind of 3D container element is [``](https://webspatial.dev/docs/api/react-sdk/react-components/Model.md). It renders static 3D content from prebuilt 3D model files in the local space in front of the 2D plane. "Static" means that while APIs can control playback of animations embedded in the model file and adjust how the model file is rendered inside this local space, application code cannot dynamically render arbitrary 3D content at runtime. ## Dynamic 3D Containers The second kind of 3D container element is [``](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md). It can dynamically render arbitrary 3D content in the local space in front of the 2D plane using a [3D Engine API](https://webspatial.dev/docs/concepts/3d-content-containers.md#3d-engine-api) that supports unified rendering. ## 3D Engine API For the [spatial computing](https://webspatial.dev/docs/concepts/spatial-computing.md) operating system and the [Spatial Runtime](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime) to understand the 3D content inside a dynamic 3D container and perform [unified rendering](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) together with other 2D and 3D content in space, arbitrary Web 3D engines built directly on WebGL/WebGPU or other low-level 3D graphics APIs cannot be used directly inside the dynamic 3D container's content. WebSpatial API includes a built-in declarative 3D engine API that combines ECS style and HTML style and supports unified rendering. This API provides a variety of ready-to-use [3D Entities](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md#3d-entity) in the form of HTML elements. Their underlying implementations include different built-in Component capabilities based on an ECS architecture, where "Component" refers to the ECS concept rather than a UI component. These capabilities are configured through HTML attributes, such as referencing [predeclared 3D assets](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md#3d-assets) or setting dimensions for [primitive entities](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md#primitive-entities). These HTML elements can only be used inside [`` as the Scene Graph root node](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md#scene-graph) in a dynamic 3D container. They do not support CSS or the 2D layout system. Instead, they use [Transform props](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md#3d-entity) from the 3D engine system to render inside a 3D coordinate system. These 3D Entities can not only be integrated into the 2D layout system and HTML/CSS content through dynamic 3D containers, but can also [attach HTML/CSS content onto the entity itself](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md#attachment-entity), letting 2D content enter the 3D rendering system as well. These [HTML elements used inside ``](https://webspatial.dev/docs/api/react-sdk/react-components/Reality.md) are also provided as React components in the [WebSpatial SDK](https://webspatial.dev/docs/introduction/getting-started.md#webspatial-sdk). ## 2D containing 3D 3D container elements act like a bridge between the CSS-based 2D layout system outside the container and the 3D rendering system based on a 3D engine inside the container, creating the new "2D containing 3D" paradigm: The entire WebSpatial App can be developed as a 2D Web App by default, using mainstream 2D Web frameworks such as React and mainstream Web APIs based on HTML/CSS. Only the local regions that truly need 3D content use the 3D-engine development paradigm on demand. The rendering performed by the 3D engine can also be integrated into the 2D rendering system, because the HTML-style 3D engine APIs provided by WebSpatial SDK can initialize and update 3D content through React's rendering model. The [Spatial Scene](https://webspatial.dev/docs/concepts/spatial-scenes.md), [spatialized HTML elements](https://webspatial.dev/docs/concepts/spatialized-html-elements.md) in a WebSpatial App, including the results of [spatial events](https://webspatial.dev/docs/concepts/natural-interactions.md#spatial-interactions) triggered on those elements, and HTML/CSS-based 2D content all belong to the 2D development paradigm. They use a left-handed coordinate system, with the origin at the top-left corner of the 2D plane, Y pointing downward, Z pointing toward the user, and lengths expressed by default in the GUI-oriented point unit (`px`). The 3D content inside a 3D container element uses the 3D development paradigm. It uses a right-handed coordinate system, with the origin at the center of the local 3D space corresponding to the container, Y pointing upward, Z pointing toward the user, and lengths expressed by default in physical world units (`m`) oriented toward real-world objects. Because all of this content is [rendered in a unified way](https://webspatial.dev/docs/concepts/spatial-computing.md#unified-rendering) by the [Spatial Runtime](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime), these coordinate systems and units can be converted freely, allowing 2D-paradigm content and 3D-paradigm content to work together, for example by aligning in space, following automatically, or interacting with each other. WebSpatial SDK provides this capability through the [unit conversion](https://webspatial.dev/docs/api/react-sdk/js-api/useMetrics.md) and [coordinate conversion](https://webspatial.dev/docs/api/react-sdk/js-api/convertCoordinate.md) APIs exported by its npm package. #### Natural Interactions Source: https://webspatial.dev/docs/concepts/natural-interactions.md Understand gaze, pinch, touch, and the spatial events WebSpatial exposes for natural interaction. Natural interactions mean that when users interact with software interfaces and virtual content in space, the interaction feels like manipulating real objects in the physical world. No control device such as an XR controller is used. Interaction relies only on hands and eyes in an intuitive and efficient way. There are two modes of natural interaction: 1. Direct interaction: the most intuitive mode, where one or both hands directly touch virtual content elements. 2. Indirect interaction: a more efficient mode that does not require raising a hand to touch. The user first "selects" a virtual content element by looking at it, then pinches fingers together to "confirm". Keeping the pinch held can continue into gestures such as drag, rotate, or magnify. ## 2D Content Interactions For 2D content, these two natural interaction modes are equivalent in effect. They are both equivalent to touch interaction on traditional screen devices. Performing direct interaction on an HTML element, where a finger directly touches it, or indirect interaction, where the user first looks at it and then pinches fingers together, both trigger Touch Events and Pointer Events. To remain compatible with older webpage code, Mouse Events and `click` are also triggered. The behavior of these Web APIs is completely equivalent to touch interaction on webpages on traditional screen devices. Taking indirect interaction as an example: 1. Before the fingers pinch together, moving the gaze position does not trigger any JS events or CSS hover state. This is equivalent to the state in touch interaction before a finger touches the screen, where webpage code has no knowledge of what the user is doing. 2. When the fingers pinch and then immediately release, the following JS events are triggered in order: 1. At the moment of pinch, the "contact" event (`pointerover`), the "enter" event (`pointerenter`), and the "down" event (`pointerdown`) are triggered at the same time. Only at the moment of pinch can the webpage obtain the interaction target and interaction position from these events, meaning it only then learns where the user is looking. 2. Next, the "touch start" event (`touchstart`) is triggered. 3. At the moment the fingers release, the "out" event (`pointerout`), the "leave" event (`pointerleave`), and the "up" event (`pointerup`) are triggered at the same time. 4. Next, the "touch end" event (`touchend`) is triggered. 5. To remain compatible with older webpage code, a series of mouse events is then simulated, including the "contact" event (`mouseover`), the "enter" event (`mouseenter`), the "move" event (`mousemove`), the "down" event (`mousedown`), and the "up" event (`mouseup`). CSS hover state is also triggered. Because this state is simulated, it is only cleared after interacting with another element. 6. Finally, the "click" event (`click`) is triggered. 3. If the fingers pinch and are not released, movement while the pinch is held continuously triggers the following events after `touchstart`, until the fingers are released: 1. The "move" event (`pointermove`), where finger movement corresponds to movement relative to the initial interaction position 2. The "touch move" event (`touchmove`) ## Hover Effect In indirect interaction mode, before the fingers pinch, the webpage does not know where the user is looking, so it cannot trigger any JS events or change any CSS state. That means a hover effect cannot be implemented in webpage code. Instead, the [Spatial Runtime](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime) must take unified responsibility for automatically rendering hover effects on the HTML element being looked at. To do this, the [Spatial Runtime](https://webspatial.dev/docs/concepts/spatial-computing.md#spatial-runtime) needs to know which "Interactive Regions" are currently visible in the webpage. Any HTML element that would make the mouse pointer change to the pointer cursor in a desktop browser is automatically recognized as an Interactive Region, including: 1. Link elements (``) 2. Interactive form elements (`