Primate Logo Primate
Guides Components

Use Marko

Add Marko components with the @primate/marko module.

1) Install

Install the Primate Marko package.

npm i @primate/marko

2) Configure

Load the Marko module in your configuration.

import config from "primate/config";
import marko from "@primate/marko";

export default config({
  modules: [
    marko(),
  ],
});

3) Write a component

Compose a component in Marko.

<!-- components/Welcome.marko -->
<h1>Hello, ${input.name}!</h1>

4) Render the template

Use response.view in a route to render the template.

// routes/index.ts
import route from "primate/route";
import response from "primate/response";

export default route({
  get() {
    return response.view("Welcome.marko", { name: "World" });
  },
});