Skip to content

Leaf Provider

After you've added the Leaf Provider package to your project, setting the provider up in code is easy.

Add to Droplet

First, register the LeafProvider.Provider with your Droplet.

import Vapor
import LeafProvider

let config = try Config()
try config.addProvider(LeafProvider.Provider.self)

let drop = try Droplet(config)


Configure Droplet

Once the provider is added to your Droplet, you can configure your Droplet to use the Leaf view renderer.


    "view": "leaf",


Learn more about configuration files in the Settings guide.


You can also set the drop.view property manually if you want to hardcode your view renderer.

import Vapor
import LeafProvider

let view = LeafRenderer(viewsDir: drop.viewsDir)
let drop = try Droplet(view: view)


Next time you boot your application, your views will be rendered using Leaf.