[](https://www.npmjs.org/package/@basis-theory/react-elements) [](https://www.npmjs.org/package/@basis-the
npm install @basis-theory/react-elements


A React wrapper for Basis Theory JS SDK.
Using Node Package Manager)
``sh`
npm install --save @basis-theory/react-elements
Using Yarn)
`sh`
yarn add @basis-theory/react-elements
For a complete list of endpoints and examples, please refer to our React docs
Initializing the SDK is done via calling the useBasisTheory hook with parameters:
`jsx
import { useBasisTheory } from '@basis-theory/react-elements';
export default function MyWrapper() {
const { bt, error } = useBasisTheory('
// instance stays undefined during initialization
if (bt) {
// able to call BasisTheory methods
}
if (error) {
// initialization error
}
}
`
You can pass the BasisTheoryReact instance down to your component tree using BasisTheoryProvider, and access it later calling the useBasisTheory hook without any parameters:
`jsx
import {
BasisTheoryProvider,
useBasisTheory,
} from '@basis-theory/react-elements';
const App = () => {
const { bt } = useBasisTheory('
elements: true,
});
return (
);
};
const MyComponent = () => {
// calling this hook with no attributes grabs the instance from Context
const { bt } = useBasisTheory();
return
$3
Elements capabilities are available when passing
elements: true in initialization options.`jsx
import {
BasisTheoryProvider,
TextElement,
useBasisTheory,
} from '@basis-theory/react-elements';const App = () => {
const { bt } = useBasisTheory('', {
elements: true,
});
return (
);
};
const MyComponent = () => {
// calling this hook with no attributes grabs the instance from Context
const { bt } = useBasisTheory();
return ;
};
`Development
The provided scripts with the SDK will check for all dependencies, build the solution and run all tests.
$3
$3
Run the following command from the root of the project:
`sh
make verify
``