Adding Leaf Provider

To add Leaf-rendering support to our Vapor application, we will need to use Leaf Provider. It uses the same Leaf package under the hood, but implements Vapor's Provider protocol so that it can be used without writing much code and specifying it as our view renderer in the droplet.json config. To add Leaf Provider to our Vapor app, we will need to perform the following steps:

  1. Open up our ShoppingListServer Xcode project and add leaf-provider as a dependency inside our Package.swift:
.package(url: "https://github.com/vapor/leaf-provider.git", .upToNextMajor(from: "1.1.0")),
  1. Next, specify it as a dependency for our App target:
.target(name: "App", dependencies: ["Vapor", "FluentProvider", "HealthcheckProvider", "MongoProvider", ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.