Skip to main content

Static assets

Wasm Workers Server allows you to serve any static asset required by your workers. For that, place any static asset in a public folder. It must be present in the root of the directory you're serving with wws.

Note that all static assets are mounted on /, so public won't be present in their paths.

For example, given the following folder structure:

.
├── index.js
└── public
└── images
└── intro.jpg
└── robots.txt

If you run wws in this folder, it will serve the following resources:

  • /: the response will be generated by the index.js worker
  • /robots.txt: the static robots.txt file
  • /images/intro.jpg: the static intro.jpg file

HTML files in public folder

HTML files are supported inside the public folder. wws will serve those without requiring the html extension.

For example, for the given folder structure:

.
├── index.js
└── public
└── images
└── intro.jpg
└── about.html

The about.html file will be served as /about.

Index file in public

An index.html can be added to the public folder and it will be mounted in /. Note that static files have a lower priority, so if there's an /index.js and /public/index.html files, the / route will be served by the former.