Static File Serving & Hot Loading
Overview
Vuer includes a built-in static file server that allows you to serve 3D models, textures, and other assets alongside your visualization. This guide covers how to configure static file serving and use hot loading for assets that change frequently during development.
Static File Configuration
The workspace Parameter
When initializing your Vuer application, you can specify where static files are served from using the workspace parameter:
URL Structure
Static files are served under the /static endpoint. For example:
Using Static Files in Your Scene
Once configured, you can reference static files in your Vuer components:
Hot Loading with ?hot
What is Hot Loading?
In Vuer, hot loading is a concept for handling assets that change frequently during development. When you mark an asset as "hot", Vuer treats it as dynamic content that should always reflect the latest version from disk.
Think of hot loading as telling Vuer:
This is especially useful when:
- Iteratively refining 3D models, textures, or materials
- Experimenting with different asset variations
- Debugging asset-related issues
Using Hot URLs
To mark an asset as hot, append ?hot to its URL:
Hot URL Syntax
The ?hot parameter can appear anywhere in the query string:
To explicitly disable hot loading, set it to false:
How Hot Loading Works
When an asset is marked as hot:
- Loader behavior: Vuer tells the browser to always check for updates
- Instant updates: When you save changes to the file, they appear immediately
- Efficient: Unchanged files are not re-downloaded (uses HTTP 304 responses)
This creates a smooth development experience where your changes are reflected instantly without manual page refreshes or cache clearing.
Development vs Production
Development Mode (Hot Assets)
During development, mark assets you're actively editing as hot:
Production Mode (Static Assets)
In production, omit the ?hot parameter to allow efficient browser caching:
Pattern: Conditional Hot Loading
You can conditionally enable hot loading based on your environment:
Using Environment Variables
For more flexibility, use environment variables to control hot loading:
Then run with:
Understanding Hot vs Static Assets
Hot Assets (?hot)
- Use for: Assets you're actively editing
- Behavior: Always reflect latest version from disk
- Performance: Minimal overhead (uses HTTP 304 for unchanged files)
- Example: Model you're refining in Blender, texture you're adjusting
Static Assets (no parameter)
- Use for: Stable assets that rarely change
- Behavior: Browser caches efficiently
- Performance: Optimal (no server requests after initial load)
- Example: Final models, published textures, shared assets
Best Practices
-
Development workflow:
- Mark assets as
?hotwhile actively editing them - Remove
?hotonce assets are finalized
- Mark assets as
-
Performance:
- Don't mark all assets as hot—only those you're currently working on
- Static assets load faster and reduce server load
-
Team collaboration:
- Use environment variables to automatically enable hot loading in development
- This prevents accidentally deploying hot URLs to production
-
Debugging:
- If you don't see changes, verify the asset has
?hotin the URL - Check the browser network tab to confirm the file is being fetched
- If you don't see changes, verify the asset has
Complete Example
Here's a complete example showing hot loading for development:
Summary
workspace: Configure where static files are served from (replaces deprecatedstatic_root)?hot: Mark frequently changing assets for instant updates- Hot loading: A development concept for assets that change often
- Production: Remove
?hotfor optimal caching and performance
Hot loading provides a seamless development experience where your asset changes are instantly visible, without the complexity of build systems or manual cache management.
See Also
- Session APIs - Managing scene updates
- Loading 3D Models - Examples of loading different formats
- Component Index - All available 3D model components