Host using GitHub Pages
Provided that out Three.js project works fully client side in a web browser just by downloading static files, e.g, the
./dist/client/ folder using GitHub pages for free.
Log into your GitHub account and create a new repository using any name that you want. E.g.,
My-Project. Note that the name needs to conform to the following rules.
- Max length 39 characters
- Alphanumeric or hyphen (-)
- Cannot start with a hyphen
- No consecutive hyphens
- Cannot be a reserved name
- Unique for your account
Upload the required files from your
bundle,jsand any other assets such as any images or 3D models needed by your project.
If your assets, such as any 3D models or images should also be placed in a sub folder, then you can edit the file name using the GitHub user interface, prepend the required folder name and follow it with a
/in front of the existing file name and then press the Commit button. See video for example.
Go to Settings/Pages and change Source to
Branch: mainand then select
\rootand then press the Save button.
You will be presented with a public URL that will point to your public GitHub page. Note that visiting this new URL to soon may result in a 404 error. It can take a minute or 2 before it will be live.
This is a very simple and minimal approach to hosting your Three.js examples for free as long as they can be fully downloaded as static files and don't require any bespoke or dynamic server side functionality or interaction.
GitHib Pages is acting just like a static HTTP web server but using a GitHub web address and an SSL certificate.