--- title: Quick Start (Deno) description: Get started with Sapling using Deno publishedAt: "2024-01-01" --- # Quick Start with Deno This guide will help you create your first Sapling website using Deno. ## Prerequisites - [Deno](https://deno.com) installed on your machine - A code editor (we recommend VS Code with the Deno extension) ## Create a New Project ```bash deno -A jsr:@sapling/create ``` Select the "Basics" template. ## Start the Development Server ```bash deno task dev ``` Your site is now running at [http://localhost:8080](http://localhost:8080)! ## Project Structure ``` my-website/ ├── components/ # Reusable UI components ├── layouts/ # Page layouts ├── pages/ # Your pages/routes ├── static/ # Static assets ├── deno.json # Project configuration └── index.ts # Entry point ``` ## Create Your First Page 1. Create a new file `pages/about.ts`: ```typescript import Layout from "../layouts/Layout.ts"; import { html } from "@sapling/sapling"; export default async function About() { return await Layout({ children: html`
`, }); } ``` 2. Add the route in `index.ts` underneath the `Home` route: ```typescript site.get("/about", async (c) => c.html(await About())); ``` Visit [http://localhost:8080/about](http://localhost:8080/about) to see your new page! ## Next Steps - Learn about [Routing](/docs/routing) - Explore [Layouts](/docs/layouts) - Check out the [Examples](https://github.com/withsapling/examples) --- title: Routing description: Learn how routing works in Sapling publishedAt: "2024-01-01" --- # Routing Sapling uses a simple and powerful routing system based on URL pattern matching. Routes are defined explicitly using the Sapling instance methods, providing a clean and type-safe way to handle HTTP requests. ## Route Handlers Routes are defined using the Sapling instance methods for different HTTP methods: ```typescript import { Sapling } from '@sapling/sapling'; const site = new Sapling(); // Basic route site.get("/", (c) => { return c.html("The requested page could not be found.
`); }); ``` The not found handler receives the same context object as regular routes and can return any valid response type. ## Request Context Each route handler receives a context object with the following properties and methods: ```typescript interface Context { req: { param: (name: string) => string; method: string; url: string; headers: Headers; }; state: RecordThis was server rendered at \${time}
Learn More${siteContent.hero.subtitle}
Comments