Skip to content

Commit 4782979

Browse files
committed
Update RedwoodSDK docs.
1 parent 18168a9 commit 4782979

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

src/content/docs/workers/framework-guides/web-apps/redwoodsdk.mdx

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 6
66
head: []
77
tags: ["full-stack"]
8-
description: Create an RedwoodSDK application and deploy it to Cloudflare Workers with Workers Assets.
8+
description: Create a RedwoodSDK application and deploy it to Cloudflare Workers.
99
---
1010

1111
import {
@@ -15,42 +15,86 @@ import {
1515
Render,
1616
PackageManagers,
1717
Steps,
18+
TabItem,
19+
Tabs,
1820
} from "~/components";
1921

2022
In this guide, you will create a new [RedwoodSDK](https://rwsdk.com/) application and deploy it to Cloudflare Workers.
2123

22-
RedwoodSDK is a composable framework for building server-side web apps on Cloudflare. It starts as a Vite plugin that unlocks SSR, React Server Components, Server Functions, and realtime capabilities.
24+
RedwoodSDK is a framework for building server-side web applications on Cloudflare. It is a Vite plugin that provides SSR, React Server Components, Server Functions, and realtime capabilities.
2325

2426
## Deploy a new RedwoodSDK application on Workers
2527

2628
<Steps>
2729
1. **Create a new project.**
2830

29-
Run the following command, replacing `<project-name>` with your desired project name:
31+
Run the following command, replacing `my-project-name` with your desired project name:
3032
<PackageManagers
3133
type="dlx"
32-
pkg="degit"
33-
args={"redwoodjs/sdk/starters/standard#main <project-name>"}
34+
pkg="create-rwsdk"
35+
args={"my-project-name"}
3436
/>
3537

3638
2. **Change the directory.**
3739
```sh
38-
cd <project-name>
40+
cd my-project-name
3941
```
4042

4143
3. **Install dependencies.**
4244
<PackageManagers type="install" />
4345

4446
4. **Develop locally.**
4547

46-
Run the following command in the project directory to start a local development server. RedwoodSDK is just a plugin for Vite, so you can use the same dev workflow as any other Vite project:
48+
Run the following command in the project directory to start a local development server. RedwoodSDK is a Vite plugin, so you can use the same development workflow as any other Vite project:
4749
<PackageManagers type="run" args={"dev"} />
4850

49-
5. **Deploy your project.**
51+
Access the development server in your browser at `http://localhost:5173`, where you should see "Hello, World!" displayed on the page.
52+
53+
5. **Add your first route.**
54+
55+
The entry point of your application is `src/worker.tsx`. Open that file in your editor.
56+
57+
You will see the `defineApp` function, which handles requests by returning responses to the client:
58+
59+
```tsx
60+
import { defineApp } from "rwsdk/worker";
61+
import { route, render } from "rwsdk/router";
62+
63+
import { Document } from "@/app/Document";
64+
import { Home } from "@/app/pages/Home";
65+
66+
export default defineApp([
67+
render(Document, [route("/", () => new Response("Hello, World!"))]),
68+
]);
69+
```
70+
71+
Add a `/ping` route handler:
72+
73+
```tsx
74+
import { defineApp } from "rwsdk/worker";
75+
import { route, render } from "rwsdk/router";
76+
77+
export default defineApp([
78+
render(Document, [
79+
route("/", () => new Response("Hello, World!")),
80+
route("/ping", function () {
81+
return <h1>Pong!</h1>;
82+
}),
83+
]),
84+
]);
85+
```
86+
87+
Navigate to `http://localhost:5173/ping` to see "Pong!" displayed on the page.
88+
89+
Routes can return JSX directly. RedwoodSDK has support for React Server Components, which renders JSX on the server and sends HTML to the client.
90+
91+
6. **Deploy your project.**
5092

5193
You can deploy your project to a `*.workers.dev` subdomain or a [Custom Domain](/workers/configuration/routing/custom-domains/), either from your local machine or from any CI/CD system, including [Cloudflare Workers CI/CD](/workers/ci-cd/builds/).
5294

5395
Use the following command to build and deploy. If you are using CI, make sure to update your [deploy command](/workers/ci-cd/builds/configuration/#build-settings) configuration accordingly.
5496
<PackageManagers type="run" args={"release"} />
5597

98+
The first time you run the command it might fail and ask you to create a workers.dev subdomain. Go to the dashboard and open the Workers menu. Opening the Workers landing page for the first time will create a workers.dev subdomain automatically.
99+
56100
</Steps>

0 commit comments

Comments
 (0)