Services
Running functions defined by Fragments on the server.
Services are functions exposed by Fragment authors to users. They are designed to be called on the server, such as in loader functions or background processing.
Basic Usage
The services
object is available on the Fragment's server-side instance.
import { createExampleFragmentInstance } from "../lib/example-fragment-server";
export async function myBackgroundProcess() {
const { getHashFromHostsFileData } = createExampleFragmentInstance().services;
setInterval(
() => {
const hash = getHashFromHostsFileData();
console.log("Hash of hosts file:", hash);
},
/* every hour */ 1000 * 60 * 60,
);
}