Frequently Asked Questions
What is Sapling?
Sapling is a lightweight web framework for building server-rendered websites with TypeScript. It's designed to be simple, fast, and easy to learn while providing modern development features.
Why should I choose Sapling over other frameworks?
Sapling offers:
- Zero client-side JavaScript by default
- Simple, intuitive HTML templating
- First-class TypeScript support
- Fast server-side rendering
- Works with any JS runtime such as Deno, Node.js, Bun, etc.
- No build step required
- Code that embraces web standards rather than fights them
Can I still use React or Svelte or other frontend frameworks?
Yes, because Sapling is more of a bare bones server side framework that generates HTML you can use any frontend framework you prefer in specific parts of your website/application. We might be biased but we think most sites are better off with plain old HTML, CSS, and JS with a sprinkling of framework specific components.
Do I need to know TypeScript to use Sapling?
While Sapling is built with TypeScript, you can write your code in JavaScript if you prefer. However, using TypeScript provides better developer experience with type checking and IDE support.
Do I need to use Deno to use Sapling?
No, Sapling works with all major JavaScript runtime environments including Deno, Node.js, Bun, and CloudFlare Workers. You'll find that we use Deno often in documentation and examples because it's our preferred runtime with built-in TypeScript support which allows us to skip the configuration and build step. However, that doesn't mean Sapling is limited to Deno.
Do I have to use Sapling for routing?
No, you can use any routing solution you prefer. We aim to be compatible with the most popular server routers out there such as Hono, Express, Koa, Oak Fastify, etc. Sapling's routing is designed to be simple, easy to use, and adds features specific to websites, but it may not meet the needs of all applications. In those cases simply use our Layout component inside of your pages to return HTML.
Why did you build Sapling when Hono already exists?
Hono is a great framework and we love it. However, it became pretty clear that at some point we would need our own router that adds specific features and optimizations for websites and applications. Hono is a great router for APIs and we think it's great for that use case. However, we think/hope you'll see over time that Sapling is a better fit for building websites and applications.
So when should I use Sapling and when should I use Hono?
It depends.
The best answer we have is if you're primarily building an API then use Hono. If you're primarily building a website or application then use Sapling. We aim to be closely compatible with Hono's context format so you can easily migrate between the two as needed.
How does routing work in Sapling?
Sapling uses a simple and powerful routing system based on URL pattern matching. Routes are defined explicitly using Sapling instance methods for different HTTP methods. For example:
site.get("/", (c) => c.html("<h1>Welcome</h1>"));
site.get("/users/:id", (c) => c.json({ id: c.req.param("id") }));
Each route handler receives a context object and can return various response types including HTML, JSON, or custom responses. For more details, see the routing documentation.
Where can I deploy Sapling applications?
Pretty much anywhere!
Sapling applications can be deployed to any platform that supports Deno or Node.js, including:
- Deno Deploy
- Google Cloud Run
- Vercel Edge Functions
- Netlify Edge Functions
- AWS Lambda
- Cloudflare Workers
- Render
- Your own server running Deno, Node.js, or Bun
How do I handle forms and user input?
Sapling provides built-in utilities for handling form submissions and user input through its server-side functions. You can access form data through the request object in your page handlers.
Is Sapling production-ready?
Yes, Sapling is being used in production by various projects. However, as with any technology choice, make sure to evaluate it against your specific requirements. We are still not at version 1.0 and are actively working on improving the framework.
Where can I get help?
- Check the documentation
- Open an issue on GitHub
- Follow the examples in our repository
How can I contribute to Sapling?
We welcome contributions! You can:
- Submit bug reports and feature requests on GitHub
- Contribute to the documentation
- Submit pull requests
- Share your Sapling projects with the community