GithubHelp home page GithubHelp logo

rafalohaki / cloudflare-worker-cra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from freemanlabstx/cloudflare-worker-cra

0.0 0.0 0.0 570 KB

A fresh CRA project which automatically deploys to Cloudflare Workers with Github Actions.

HTML 14.86% CSS 8.03% JavaScript 77.11%

cloudflare-worker-cra's Introduction

Cloudflare Workers <3 Create React App

Deploy to Cloudflare Workers

Cloudflare Workers is a serverless platform which offers a very cheap and highly scalable way to serve your React application and run other serverless code. This is a fresh CRA project which automatically deploys to Cloudflare Workers with Github Actions, which you can fork and set up in a matter of minutes.

This setup costs $5/mo for 10 million requests per month.

Pre-requisites

You'll need a Cloudflare Workers account with

  • A workers domain set up
  • The Workers Unlimited subsciption ($5/mo)

Setup

To start your own project based on this template, just click "Use this template" or visit this link: https://github.com/lappalj4/cloudflare-worker-cra/generate

Set your app name

First, open up wrangler.toml and change the name property - this will be the subdomain that your app is published on.

Your Cloudflare workers domain will be of the format {your-worker-domain}.workers.dev. When you publish an app on a Worker, it will be published on a subdomain corresponding to your app name - cloudflare-worker-cra.{your-worker-domain}.workers.dev by default.

Get your Account ID and create a new API Token

To get your account ID:

To create a new API Token:

  • Go to https://dash.cloudflare.com/profile/api-tokens > Create Token
  • Give your token a name (i.e. Github Actions)
  • Choose start with template
  • Select the "Edit Cloudflare Workers" template
  • Account Resources > Include > {your account}
  • Zone Resources > Include > All zones from account > {your account}

Once done, navigate to your GitHub repository > Settings > Secrets and add the following secrets:

- Name: CF_API_TOKEN
- Value: your-api-token

- Name: CF_ACCOUNT_ID
- Value: your-account-id

PS: Your account id isn't really a secret and could be shared freely, but I feel it's just more convenient to store this configuration within the GitHub secrets instead of the repository code.

That's it! Now, just push a new commit into master and you'll find your React app deployed at {app-name}.{your-worker-domain}.workers.dev

cloudflare-worker-cra's People

Contributors

juiceo avatar kristianfreeman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.