Luigi Client contains a library that allows your application to use all features of the Luigi framework.
Install the client in your project using npm:
npm install @luigi-project/client
Import the client in places where you want to use it, depending on the environment of your choice:
Add this line to the imports section of the src/main.js
file:
import LuigiClient from '@luigi-project/client';
Add this line to the imports section of the src/app/app.component.ts
file:
import LuigiClient from '@luigi-project/client';
Add this to the webapp/home/Home.controller.js
file:
sap.ui.define(
[
'sap/ui/core/mvc/Controller',
'sap/ui/core/UIComponent',
'luigi/demo/libs/luigi-client/luigi-client'
],
Add this line to the imports section of the src/main.js
file:
import LuigiClient from '@luigi-project/client';
Add this line to the imports section of the src/App.js
file:
import LuigiClient from '@luigi-project/client';
TIP: You can find an Next.JS example using Luigi Client here.
- Add this line to the imports section of the
src/App.js
file:
import LuigiClient from '@luigi-project/client';
- Add the
useEffect
function:
import { useEffect } from 'react'
export default function Home() {
// recommended by https://nextjs.org/docs/migrating/from-create-react-app#safely-accessing-web-apis
useEffect(() => {
var luigiClient = require('@luigi-project/client');
console.log("Load LuigiClient in useEffect: " + luigiClient);
}, [])
If you are not using any bundler, Luigi is also available as a global object:
window.LuigiClient
TIP: You can see Luigi Client in action by running the Angular example application.
This section contains additional instructions and guidelines you can use to work with Luigi Client.
In the Luigi Client API, you will find functions that will allow you to configure your micro frontend in the context of the main Luigi Core app.
For example, if you want to use the function addInitListener
in order to display a Luigi alert in the micro frontend, it can look like this:
useEffect(() => {
const LuigiClient = require('@luigi-project/client');
LuigiClient.addInitListener(function(context) {
LuigiClient.showAlert({text: 'Hello'});
});
}, []);