Quick Start
In this quick start you’ll go from zero to request/response in seconds and deploy to production in minutes!
Create a new project by running the following command, replacing <project-name>
with your project name:
npx degit redwoodjs/sdk/starters/standard <project-name>
Start developing
Install the dependencies
cd <project-name>pnpm install
cd <project-name>npm install
cd <project-name>yarn install
Run the development server
RedwoodSDK is just a plugin for Vite, so you can use the same commands to run the development server as you would with any other Vite project.
pnpm dev
npm run dev
yarn dev
VITE v6.2.0 ready in 500 ms
➜ Local: http://localhost:5173/➜ Network: use --host to expose➜ press h + enter to show help
Access the development server in your browser, by default it’s available at http://localhost:5173, where you should see “Hello World” displayed on the page.
How exciting, your first request/response in RedwoodSDK!
Your first route
The entry point of your webapp is src/worker.tsx
, open that file in your favorite editor.
Here you’ll see the defineApp
function, this is the main function that “defines your webapp,” where the purpose is to handle requests by returning responses to the client.
import { defineApp } from "@redwoodjs/sdk/worker";import { route, render } from "@redwoodjs/sdk/router";
import { Document } from "@/app/Document";import { Home } from "@/app/pages/Home";
export default defineApp([ render(Document, [route("/", () => new Response("Hello, World!"))]),]);
You’re going to add your own route, insert the "/ping"
route handler:
import { defineApp } from "@redwoodjs/sdk/worker";import { route, render } from "@redwoodjs/sdk/router";
export default defineApp([ render(Document, [ route("/", () => new Response("Hello, World!")), route("/ping", function () { return <h1>Pong!</h1>; }), ]),]);
Now when you navigate to http://localhost:5173/ping you should see “Pong!” displayed on the page.
Deploy to production
RedwoodSDK is built for the Cloudflare Development Platform. You can deploy your webapp to Cloudflare with a single command:
pnpm release
npm run release
yarn release