@nura-js/react
v0.1.1
Published
React adapter for Nura.js
Readme
@nura-js/react
Official React adapter for consuming the Nura.js runtime with declarative components and hooks.
Installation
pnpm add @nura-js/reactUsage Example
import { createRegistry } from '@nura-js/core';
import { NuraProvider, useNuraAction } from '@nura-js/react';
const registry = createRegistry({
// define actions and agents
});
export function App() {
return (
<NuraProvider registry={registry}>
<OrdersButton />
</NuraProvider>
);
}
function OrdersButton() {
const action = useNuraAction('open_orders');
return (
<button onClick={() => action?.run?.()} data-nu-act={JSON.stringify(action?.spec)}>
Open orders
</button>
);
}Key APIs
NuraProviderinjects the registry into the React tree.useNurareturns theNuraruntime and helpers.useNuraActionresolves actions by name and exposes execution helpers.useNuraPermissionevaluates declarative permissions inside components.NuraElementrenders helpers that syncdata-nu-*attributes.
Type References
NuraProviderProps— provider configuration for registry and context.UseNuraReturn— runtime and registry values fromuseNura.UseNuraActionOptions— options foruseNuraActionsuch as scope and arguments.NuraElementProps— props for the helper component exposing accessible attributes.
Additional Resources
- Repository: https://github.com/nura-ia/nurajs
- Issues: https://github.com/nura-ia/nurajs/issues
