0.4.0 • Published 3 years ago
@topkit/router v0.4.0
@topkit/router
Routing utilities for micro frontends (MFE)
How to install
yarn add @topkit/router
Usage
In the host application or in the environment where you component is mounted
add RouteContext
wrapper to provide route
function for your MFE application:
// Host app, ex. Staff Portal
// App.tsx
import {RouteContext} from '@topkit/router'
// route function to format urls (example)
const route = (path: string) => {
const result = path.replace('/platform/staff', '')
if (BETA_ENABLED_PATHS.includes(result)) {
return 'https://staff-portal.toptal.net/' + result
}
return 'https://staging.toptal.net/platform/staff' + result
}
...
return (
<RouteContext.Provider value={route}>
{children}
</RouteContext.Provider>
)
In your MFE application you will be using this RouteContext
provider by using
Link
component from @topkit/router
:
// MFE application
import {Link} from '@topkit/router'
...
return (
...
<Link href='/platform/staff/talents/1765560'>Elisabeth Marks</Link>
// or
<Link href='/talents/1765560'>Elisabeth Marks</Link>
...
)
Internally Link
component is using route
function provided by RouteContext
provider to format href
.
Additional Resources
0.4.1-alpha-spc-955-add-message-bus.83
3 years ago
0.4.0
3 years ago
0.3.3-alpha-create-gateway-link.61
3 years ago
0.3.2
3 years ago
0.3.1
3 years ago
0.3.1-alpha-create-gateway-link.53
3 years ago
0.3.0
4 years ago
0.2.7-alpha-fx-test-alpha-packages.60
4 years ago
0.2.7-alpha-fx-test-alpha-packages.59
4 years ago
0.2.7-alpha-fx-test-alpha-packages.57
4 years ago
0.2.7-alpha-fx-test-alpha-packages.56
4 years ago
0.2.7-alpha-fx-test-alpha-packages.55
4 years ago
0.2.6-alpha-debug.3
4 years ago
0.2.4
4 years ago
0.3.0-alpha.7
4 years ago
0.2.5
4 years ago
0.2.4-fx-test-alpha-packages.4
4 years ago
0.2.3
4 years ago
0.2.2
4 years ago
0.2.1
4 years ago
0.2.0
4 years ago
0.1.0
4 years ago