Getting Started
#
Project SetupWe'll start by using create-next-app for creating a new Next.js app.
now we will add two more dependencies: Express.js and Krabs:
We will also need to create a custom server for handling our Next.js instance. If you haven't already, please read the caveats section.
Let's create a new file called server.js
. It will be the entry point of our custom Express.js server.
As you can see, the krabs function accepts four parameters:
req
: Express.js request objectres
: Express.js response objecthandle
: the Next.js route handlerapp
: the Next.js app object
It can actually accept one more argument, the krabs configuration, which is basically a JavaScript object. There's another way for configuring the multi-tenant settings for our krabs middleware: by creating a .krabs.js file inside of the root folder, and we'll proceed like that.