Skip to main content
Web Exporting as Code

Exporting as Code

Code Export Options

Spline allows you to export the code of your scene as:

  • Vanilla JS

    • πŸ“„ Runtime Docs: https://www.npmjs.com/package/@splinetool/runtime

  • Three.js

    • πŸ“„ Loader Docs: https://www.npmjs.com/package/@splinetool/loader

  • React

    • πŸ“„ React Docs: https://github.com/splinetool/react-spline

  • Next.js

    • πŸ“„ Next.js Docs: https://github.com/splinetool/react-spline#nextjs

  • react-three-fiber

    • πŸ“„ r3f Docs: https://github.com/splinetool/r3f-spline

Animations and events are only enabled when exporting to Vanilla js and React.

How to Export

  1. Once you’re happy with your scene, press the Export button on the toolbar.

  2. Select β€œCode” on the left sidebar and choose from any of the code types available on the top dropdown, then wait for the URL to be generated.

  3. A toast notification will appear to let you know when your URL is ready.

  4. You can copy the code, open it as a CodeSandbox project, or download the local files to host it yourself.

  5. Multiple properties can be adjusted under .

You can download the code exports and host them on your own server.

About the Web Content Export (Vanilla JS)

  1. Following the steps above you can export as Web Content by choosing Vanilla JS as the code type under the dropdown.

  2. You will find a button at the bottom of the panel to download the content as a .zip file.

  3. If you want to play the experience, you need to run a localserver. Open your OS terminal or console from the uncompressed folder path and run: python -m SimpleHTTPServer

The files saved from the "Web Content" option are the same used for the "Public URL". This is the way to add the files directly to your web project.

The file structure might look something like the following:

Note: Inside the index.html there is a Canvas element, which runs the WebGL 3D graphics.

Drafts

You can use drafts to version your exports. Each Draft is a snapshot of your scene.

The Draft labeled Production is the one to which the main URL is pointing to. If there are additional changes on the scene or export settings, click Generate Draft or Promote to Production for the code to reflect the latest changes.

There is one production code, and many drafts can be created as needed under the Drafts tab. Any of the Drafts can be promoted to Production.

Handling events outside of Spline

Learn more about Code API for Web: Code API for Web

You can handle events outside of Spline and use them to manipulate your spline objects.

Here are 2 examples:

  1. Example 1

  2. Example 2

πŸ‘‰ Related docs

,