Skip to main content
1

Install the package

Photo Sphere Viewer is available on npm and via CDN. The core package depends on Three.js.
npm install @photo-sphere-viewer/core
You can also download the latest release and host the files yourself.
2

Add a container element

The viewer renders inside a DOM element. Give it explicit dimensions — the viewer will fill the container completely.
<!-- for optimal display on high DPI devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- the viewer container must have a defined size -->
<div id="viewer" style="width: 100vw; height: 100vh;"></div>
3

Initialize the viewer

Import the Viewer class and point it at your container and panorama image.
Importing from a CDN requires an import map and a type="module" script tag.
<head>
    <!-- for optimal display on high DPI devices -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core/index.min.css" />
</head>

<!-- the viewer container must have a defined size -->
<div id="viewer" style="width: 100vw; height: 100vh;"></div>

<script type="importmap">
    {
        "imports": {
            "three": "https://cdn.jsdelivr.net/npm/three/build/three.module.js",
            "@photo-sphere-viewer/core": "https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core/index.module.js"
        }
    }
</script>

<script type="module">
    import { Viewer } from '@photo-sphere-viewer/core';

    const viewer = new Viewer({
        container: document.querySelector('#viewer'),
        panorama: 'path/to/panorama.jpg',
    });
</script>

Notes on the panorama image

The panorama option expects an equirectangular projection image by default. This is the standard output format from 360° cameras.
If your image does not cover a full 360°×180° sphere, it will appear deformed. Fix this by providing cropping data via the equirectangular adapter options.
Other panorama formats are supported through adapters:
  • Cubemap faces
  • Tiled equirectangular and cubemap images
  • Equirectangular and cubemap video
See Adapters overview for details.

Next steps

Configuration

Explore all viewer options: zoom, position, navbar, caching, and more.

Adapters

Load cubemaps, tiled images, and video panoramas.

Plugins

Add markers, virtual tours, maps, and more.

Methods & events

Programmatically control the viewer and react to user interactions.

Build docs developers (and LLMs) love