Micro-App Integration
Introduction
React integration with @esmx/router is implemented through the @esmx/router-react package. This package provides React-specific hooks and components, while you can also use the router's built-in micro-app pattern via the apps callback for low-level integration.
@esmx/router-react provides useRouter(), useRoute(), RouterLink, RouterView, and other APIs, enabling quick integration of routing functionality. If you need a fully custom implementation, you can also build your own hooks and components using standard React patterns via the apps callback in RouterOptions.
Installation
Type Definitions
RouterMicroAppOptions
- Type Definition:
Configuration object returned by the apps callback, defining the lifecycle hooks for mounting, unmounting, and SSR-ing the React application.
RouterMicroAppCallback
- Type Definition:
A function that receives the Router instance and returns the micro-app lifecycle hooks. The router instance can be passed to React components via props or context.
RouterMicroApp
- Type Definition:
The type accepted by the apps option in RouterOptions. Can be a single callback function or a record of named micro-app callbacks for multi-app routing.