Spectral Modal
Calculate your Spectral Score in simple steps
How to install the SDK?
npm i @spectral-finance/spectral-modal
or
yarn add @spectral-finance/spectral-modal
How to use it?
SpectralProvider
and wrap your app
1- Import Wrap the main app component with SpectralProvider
and set your app's logo
URL for the UI.
import { SpectralProvider } from "@spectral-finance/spectral-modal";
export const App = () => {
return (
<SpectralProvider logo="yourLogoImageURL" partnerId="yourPartnerId">
<RouterOrHome />
</SpectralProvider>
);
};
2- Invoke Spectral score hook calculation
The useSpectral
hook can be used anywhere inside the app context. Once the score is calculated it will be served within the score
key provided by the hook.
import { SpectralProvider } from "@spectral-finance/spectral-modal";
export const Home = () => {
const { start, score } = useSpectral();
const [myScore, setMyScore] = useState();
useEffect(() => {
if (!score) {
console.log("Score not calculated");
return;
}
console.log(`Hooray! your score is ${score}`);
setMyScore(score);
}, [score]);
return (
<div>
<button type="button" onClick={start}>
Calculate Spectral Score
</button>
</div>
);
};