Skip to content

nichoth/template-cloudflare-worker

Repository files navigation

template cloudflare worker

A template for applications using preact, htm, typescript, and cloudflare as host. Use tapout for tests in a browser environment.

See template-ts-preact-htm-app for the same thing, but not using cloudflare.

See template-ts-preact-htm for something similar, but for dependency modules.

Contents

Use

  1. Use the template button in github. Or clone this then rm -rf .git && git init.
  2. Then npm i && npm init.
  3. Edit the source code in src/.
  4. Setup the environment variables:
    mv .dev.vars.example .dev.vars
  5. Write docs — mv README.example.md README.md + edit the readme file

Featuring

Develop

Use the vite Cloudflare plugin to start a local dev environment.

npm start

Cloudflare

Use the Cloudflare GUI to import your repo.

Deploy from the CLI with npx wrangler deploy.

Frontend Architecture

See this article for more details about application architecture.

We create application state and logic in the file ./src/state.ts. This exports static functions, creates a state object, and sets up URL routing.

In the view code, you would call the functions exposed in state with a state instance in response to application events.

Notes

About

Template for Cloudflare workers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors