Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/refresh-react-workers-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"create-cloudflare": patch
---

Update the design of the React Workers starter

The React Workers template now follows the latest Vite React starter more closely, so new projects get the refreshed upstream design alongside the existing Cloudflare integration.

This file was deleted.

174 changes: 132 additions & 42 deletions packages/create-cloudflare/templates/react/workers/js/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from './assets/vite.svg'
import cloudflareLogo from './assets/Cloudflare_Logo.svg'
import cloudflareLogo from './assets/cloudflare.svg'
import heroImg from './assets/hero.png'
import './App.css'

function App() {
Expand All @@ -10,47 +11,136 @@ function App() {

return (
<>
<div>
<a href='https://vite.dev' target='_blank'>
<img src={viteLogo} className='logo' alt='Vite logo' />
</a>
<a href='https://react.dev' target='_blank'>
<img src={reactLogo} className='logo react' alt='React logo' />
</a>
<a href='https://workers.cloudflare.com/' target='_blank'>
<img src={cloudflareLogo} className='logo cloudflare' alt='Cloudflare logo' />
</a>
</div>
<h1>Vite + React + Cloudflare</h1>
<div className='card'>
<button
onClick={() => setCount((count) => count + 1)}
aria-label='increment'
>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<div className='card'>
<button
onClick={() => {
fetch('/api/')
.then((res) => res.json())
.then((data) => setName(data.name))
}}
aria-label='get name'
>
Name from API is: {name}
</button>
<p>
Edit <code>worker/index.js</code> to change the name
</p>
</div>
<p className='read-the-docs'>
Click on the Vite and React logos to learn more
</p>
<section id="center">
<div className="hero">
<img src={heroImg} className="base" width="170" height="179" alt="" />
<img src={reactLogo} className="framework" alt="React logo" />
<img src={viteLogo} className="vite" alt="Vite logo" />
</div>
<div>
<h1>Get started with Cloudflare</h1>
<p>
Edit <code>src/App.jsx</code> or <code>worker/index.js</code> and save to test <code>HMR</code>
</p>
</div>
<ul style={{ display: 'flex', gap: '1rem', listStyle: 'none', padding: 0 }}>
<li>
<button
className="counter"
onClick={() => setCount((count) => count + 1)}
>
Count is {count}
</button>
</li>
<li>
<button
className="counter"
onClick={() => {
fetch('/api/')
.then((res) => res.json())
.then((data) => setName(data.name))
}}
aria-label='get name'
>
Name from API is: {name}
</button>
</li>
</ul>


</section>

<div className="ticks"></div>

<section id="next-steps">
<div id="docs">
<svg className="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#documentation-icon"></use>
</svg>
<h2>Documentation</h2>
<p>Your questions, answered</p>
<ul>
<li>
<a href="https://vite.dev/" target="_blank">
<img className="logo" src={viteLogo} alt="" />
Explore Vite
</a>
</li>
<li>
<a href="https://react.dev/" target="_blank">
<img className="button-icon" src={reactLogo} alt="" />
Learn more
</a>
</li>
<li>
<a href="https://workers.cloudflare.com/" target="_blank">
<img className="button-icon" src={cloudflareLogo} alt="" />
Workers Docs
</a>
</li>
</ul>
</div>
<div id="social">
<svg className="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#social-icon"></use>
</svg>
<h2>Connect with us</h2>
<p>Join the Vite community</p>
<ul>
<li>
<a href="https://github.com/vitejs/vite" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#github-icon"></use>
</svg>
GitHub
</a>
</li>
<li>
<a href="https://chat.vite.dev/" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#discord-icon"></use>
</svg>
Discord
</a>
</li>
<li>
<a href="https://x.com/vite_js" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#x-icon"></use>
</svg>
X.com
</a>
</li>
<li>
<a href="https://bsky.app/profile/vite.dev" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#bluesky-icon"></use>
</svg>
Bluesky
</a>
</li>
</ul>
</div>
</section>

<div className="ticks"></div>
<section id="spacer"></section>
</>
)
}
Expand Down

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Loading