UNPKG

neura-sdk

Version:

TypeScript SDK for interacting with the Neura AI API

18 lines (17 loc) 708 B
import { jsx as _jsx } from "react/jsx-runtime"; import React, { createContext, useContext } from 'react'; import { NeuraSDK } from '../core/neura-sdk'; const NeuraContext = createContext(undefined); export const NeuraProvider = ({ config, children }) => { // Create the SDK instance const sdk = React.useMemo(() => new NeuraSDK(config), [config]); const value = React.useMemo(() => ({ sdk }), [sdk]); return _jsx(NeuraContext.Provider, { value: value, children: children }); }; export const useNeura = () => { const context = useContext(NeuraContext); if (context === undefined) { throw new Error('useNeura must be used within a NeuraProvider'); } return context; };