
Security News
Socket Integrates With Bun 1.3’s Security Scanner API
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
@heymantle/polaris
Advanced tools
A react interface for interacting with the Mantle App API and drop-in components for your billing UI.
You can install the Mantle react package using npm:
$ npm install @heymantle/polaris
Include the MantleProvider
react context somewhere near the root of your component tree, after you have access to your customer / shop data, you'll need the stored Mantle customer token from the identify
request you did server-side. For example:
import { MantleProvider } from "@heymantle/react";
const App = (Component) => {
const [shop, setShop] = useState();
const fetchShop = async () => {
const response = await fetch('/api/shop');
setShop(await response.json());
}
useEffect(() => {
fetchShop();
}, [])
if (!shop) {
return <Loading />;
}
ReactDOM.render(
<BrowserRouter>
<AppFrame host={host}>
<MantleProvider
appId={process.env.MANTLE_APP_ID}
customerApiToken={shop.mantleApiToken}
apiUrl={process.env.MANTLE_API_URL}
>
<Component />
</MantleProvider>
</AppFrame>
</BrowserRouter>,
document.getElementById("app-container")
);
};
Further down the stack you can then use the useMantle
hook for most data and operations, for example:
import { useMantle } from "@heymantle/react";
import { HorizontalPlanCards } from "@heymantle/polaris";
const HomePage = () => {
const { customer, subscription, plans, subscribe, cancelSubscription, pushEvent } = useMantle();
useEffect(() => {
pushEvent({
eventName: 'page_view',
properties: {
path: window.location.href,
},
});
}, [window.location]);
return (
<div>
{customer.subscription ? (
<div>
<span>You're currently susbcribed to: {customer.subscription.plan.name}</span>
<button
onclick={async () => {
await cancelSubscription();
}}
>
Cancel subscription
</button>
</div>
) : (
<HorizontalPlanCards
customer={customer}
plans={plans}
onSubscribe={async ({ planId, discountId }) => {
const subscription = await subscribe({ planId, discountId });
open(subscription.confirmationUrl, "_top");
}}
/>
)}
</div>
)
};
Documentation is available at https://heymantle.com/docs/surfacing-mantle-data.
FAQs
Mantle's frontend component library
The npm package @heymantle/polaris receives a total of 989 weekly downloads. As such, @heymantle/polaris popularity was classified as not popular.
We found that @heymantle/polaris demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.
Security News
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.