Skip to content

Hosting

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:

Terminal window
pnpm build

This 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 dist folder.
  • GitHub gives you a familiar pull request workflow and acts as the shared backend for both Cloudflare deployments and Administration UI content updates.
  1. Create a GitHub account: If you do not have one yet, sign up at GitHub.
  2. 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.
  3. 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.
  4. Push the site to GitHub: Push your local site to the new GitHub repository by running these commands from your site folder:
    Terminal window
    git remote add origin https://github.com/your-org/your-repo.git
    git push --set-upstream origin --all
    Replace your-org and your-repo with your actual values.
  1. Create a Cloudflare Account: Sign up at Cloudflare if you don’t have an account.
  2. Add a Workers config: Create a wrangler.jsonc file in your site root. Use this config to serve the dist folder 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
    }
    ]
    }
  3. Create a Workers application: In the Cloudflare dashboard, open Compute (Workers) and create a new Worker connected to your GitHub repository.
  4. Configure the build and deploy commands: Set pnpm build as the build command and pnpx wrangler deploy as the deploy command.
  5. View your site: Cloudflare provides a workers.dev preview URL. Each time you push a new commit to GitHub, Cloudflare can rebuild and deploy the site. If preview_urls is enabled, you can also use preview deployments while testing changes.

You can use Cloudflare Domains to purchase a domain registration.

To configure a custom domain:

  1. Purchase a domain from Cloudflare Domains.
  2. Follow the instructions in the Cloudflare dashboard to attach your custom domain to your Worker route.

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.