Skip to content

Power your frontend ​

Build APIs that power your mobile apps, React frontends, and third-party integrations.

APIs sit behind your mobile apps, frontend interfaces, and third-party integrations. Leaf helps you build them fast, keep them secure, and maintain them without headaches.

Getting started ​

bash
leaf create my-app --api
cd my-app
leaf serve

You're live and ready to build.

Start with a real API, not a blank page ​

Out of the box, you can build:

  • πŸ” User authentication (login, signup, JWT)
  • πŸ“± Mobile app backends
  • πŸ”— Third-party integrations
  • πŸ’³ Payment webhooks
  • 🌐 Frontend APIs (for React, Vue, Svelte)

There's no wiring to do, and no guessing about structure.

Your API is ready for AI ​

Leaf MVC gives agents shared project memory out of the box. Open an agent in the project and it reads .leaf/CONTEXT.md alongside your routes, controllers, models, and database files, then syncs useful structural changes back into the context.

Tell it:

"Add a stripe webhook endpoint"

"Create a user authentication API"

"Build a todo list API"

No AI setup or context command is required.

If you use an external assistant without access to the project folder, run leaf context and paste the compact output into your conversation.

Project Structure ​

Leaf organizes your API into a simple, convention-based structure:

  • Routes: Define your endpoints
  • Controllers: Handle requests and return JSON
  • Models: Interact with your database
  • Database: Your schema and migrations
bash
β”œβ”€β”€β”€app
β”‚   β”œβ”€β”€ controllers
β”‚   β”œβ”€β”€ database
β”‚   β”œβ”€β”€ models
β”‚   └── routes
└───public

Ready for real users ​

Once your API is built, tested, and ready, deploy it to Heroku, Fly.io, DigitalOcean, or any shared hosting service.

For your frontend, upload to Google PlayStore or the Apple App Store, use Netlify, Vercel, or GitHub Pages for web apps.

Are you stuck? Working with MVC can be a bit challenging if you are just starting out because of the overly strict separation of concerns. If you are stuck at any point, feel free to ask for help in the Leaf Discord server, or consider building an MVP using the Basic Leaf setup. While it is not as structured as MVC, it is a great way to get started with Leaf.

Now that you have an API live, here's what you need to know next:

  • Routing

    Learn more about routing in Leaf, dynamic routes, middleware and more.

  • Using Controllers

    Controllers are the 'C' in MVC, and separate your logic from your views.

  • Using Models

    Models are the 'M' in MVC, and let you interact with your database programmatically.

  • Authentication

    Learn about signing users in and out, user management, roles + permissions, and more.