FAQ

Everything you need to know about jeasx

Is there something like a context object similar to React?

Yes, jeasx includes the fastity-request-context by default. You can populate the request context in an endpoint (e.g., a guard):

import { requestContext } from "@fastify/request-context";

export default function RootGuard({ request, reply }) {
  requestContext.set("date", new Date());
}

Later, you can access the context in any server-side code of your project:

import { requestContext } from "@fastify/request-context";

function CurrentDate() {
  return requestContext.get("date").toISOString();
}
Can I post-process the resulting HTML?

If you want to prettify the HTML output, you can wire up a response handler in any endpoint (e.g. a guard). The response handler takes the resulting payload as a parameter and returns the modified payload.

import * as prettier from "prettier";
...
export default function RootGuard({ request, reply }) {
  requestContext.set("response", async (payload) => {
    return typeof payload === "string" &&
      String(reply.getHeader("content-type")).startsWith("text/html")
      ? await prettier.format(payload, { parser: "html" })
      : payload;
  });
}
Is it possible to use SASS/SCSS?

Certainly! Please check out the GitHub repository of this website to see how things should be wired.

How to use a Browsersync with Jeasx?

If you want to reload CSS automagically, start Browsersync in proxy-mode in a second terminal:

npx -y browser-sync start -w -f "dist/**/index.css" -p localhost:3000
What are the hosting options for a jeasx project?

Jeasx provides two different hosting modes tailored to meet your specific needs: traditional hosting on a node server or a serverless approach. For effortless node-based hosting, I highly recommend a platform like Railway, which seamlessly operates jeasx without the need for additional configurations. If you prefer a serverless approach, Vercel is the perfect fit, where jeasx provides the necessary configurations out of the box.