Hosting
Hosting your media library
Section titled “Hosting your media library”Before you begin, you need a local LightNet site. If you have not created one yet, start with the Getting started guide. More experienced users may prefer to start with the minimal-template.
We recommend hosting LightNet sites with GitHub and Cloudflare Workers. This is the standard setup for new LightNet sites.
Set up hosting on GitHub and Cloudflare Workers
Section titled “Set up hosting on GitHub and Cloudflare Workers”To build your site locally, run the following command from your site folder:
pnpm buildThis creates a dist folder containing the generated static site files. Cloudflare Workers can run the same build and serve the resulting folder directly from Cloudflare’s global network.
Use GitHub as the main home for your LightNet site. It stores your source files, receives content changes from the Administration UI, and triggers Cloudflare Workers deployments whenever you push new commits.
GitHub and Cloudflare Workers both offer free-tier starting points for static sites.
- Cloudflare Workers can serve static assets from your generated
distfolder. - GitHub gives you a familiar pull request workflow and acts as the shared backend for both Cloudflare deployments and Administration UI content updates.
Set up GitHub
Section titled “Set up GitHub”- Create a GitHub account: If you do not have one yet, sign up at GitHub.
- Create a GitHub organization: Every LightNet site should be managed separately within a GitHub organization. This keeps site access and ongoing maintenance consistent and easier to manage.
- Create a new repository: Within the GitHub organization, create a new repository for your LightNet site. A private repository is usually the best choice if your site is not meant to be public.
- Push the site to GitHub: Push your local site to the new GitHub repository by running these commands from your site folder:
Replace
Terminal window git remote add origin https://github.com/your-org/your-repo.gitgit push --set-upstream origin --allyour-organdyour-repowith your actual values.
Set up Cloudflare Workers
Section titled “Set up Cloudflare Workers”- Create a Cloudflare Account: Sign up at Cloudflare if you don’t have an account.
- Add a Workers config: Create a
wrangler.jsoncfile in your site root. Use this config to serve thedistfolder as static assets:wrangler.jsonc {"name": "your-site","compatibility_date": "2026-03-31","workers_dev": true,"preview_urls": true,"send_metrics": false,"assets": {"directory": "./dist","not_found_handling": "404-page"},"routes": [{"pattern": "your-site.example","custom_domain": true}]} - Create a Workers application: In the Cloudflare dashboard, open Compute (Workers) and create a new Worker connected to your GitHub repository.
- Configure the build and deploy commands: Set
pnpm buildas the build command andpnpx wrangler deployas the deploy command. - View your site: Cloudflare provides a
workers.devpreview URL. Each time you push a new commit to GitHub, Cloudflare can rebuild and deploy the site. Ifpreview_urlsis enabled, you can also use preview deployments while testing changes.
Configure a Cloudflare domain
Section titled “Configure a Cloudflare domain”You can use Cloudflare Domains to purchase a domain registration.
To configure a custom domain:
- Purchase a domain from Cloudflare Domains.
- Follow the instructions in the Cloudflare dashboard to attach your custom domain to your Worker route.
Alternative: host your site elsewhere
Section titled “Alternative: host your site elsewhere”You can host your LightNet site on another file server if required. From your local site folder, run the pnpm build command described above. This creates a folder named dist containing the static HTML, CSS, JavaScript, and asset files. Upload that folder to your file server.