You may need to fetch you micro-frontends at the server-side. This client is make for it!
$ npm install ragu-client-nodeimport RaguClient from 'ragu-client-node';
const client = new RaguClient();
const component = await client.fetchComponent('https://a-squad-ragu-server.organization.com/components/hello-world');
component.stylesheets(); // <style src="https://a-squad-ragu-server.organization.com/assets/hello-world.css">
component.html(); // html-content-from-server
component.toRaguDOM(); // <ragu-component src="https://a-squad-ragu-server.organization.com/components/hello-world">...html-content-from-server</ragu-component>To be isomorphic friendly and dependency-free, Ragu Client Node uses fetch API. As node does not implement fetch API you will need a polyfill, such as cross-fetch and abort-controller.
$ npm install cross-fetch abort-controllerRegistering polyfill:
require('cross-fetch/polyfill');
require('abort-controller/polyfill');If you already use axios as HTTP client you could use the ragu axios client.
import {RaguClient} from "ragu-node-client";
import {AxiosRequestAdapter} from "ragu-node-client/adapters/axios";
const client = new RaguClient({
requestAdapter: new AxiosRequestAdapter()
});You can specify a request timeout. The default is 5000ms.
When a timeout occurs the fetchComponent promise will be reject with a new Error('Timeout') error.
const client = new RaguClient({
timeout: 1000
});