Skip to content

cloudflare/workers-react-pwa-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Cloudflare GraphQL Gateway

Workers React Example

Combining the power of Cloudflare Workers and React will allow you to render the same React code you would on the browser on Cloudflare Workers.

Dependencies

Instructions

  • yarn preview

Static hosting

In order for this application to work, you'll have to be able to serve /worker.js from your own origin. This example uses terraform to upload the worker script to Google Cloud Storage, but you are welcome to use any other origin.

Terraform

If you'd like to use terraform to upload your worker scripts, you'll need a vars file with the following variables

# Cloudflare variables
variable "cloudflare_email" {
  default = "dmr@bell-labs.com"
}

variable "cloudflare_token" {
  default = "00000000000000000000000000"
}

# GCP exmaple variables
variable "project" {
  default = "my-project"
}

variable "zone" {
  default = "buzzwords.app"
}

variable "bucket" {
  default = "buzzwords"
}

after adding this file as vars.tf (terraform will pickup any .tf extension file) do terraform init and terraform apply

About

Cloudflare Workers allow you to write JavaScript which runs on all of Cloudflare's 150+ global data centers.

React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.