near-react-hooks
v1.2.3
Published
[](https://github.com/mehtaphysical/near-react-hooks/actions/workflows/test.yml) [
)You can more finely tune the NEAR configuration by passing additional props
no the NearProvider. See the docs for more information.
Once the application is wrapped with the NearProvider your can access the
NEAR connection, the NEAR wallet, and NEAR contract using react hooks from
any component in the application.
import React, { useEffect } from 'react'
import { useNear, useNearWallet, useNearContract } from 'near-react-hooks';
export default function App() {
const near = useNear()
const wallet = useNearWallet()
const contract = useNearContract('dev-123457824879', {
viewMethods: ['getCount'],
changeMethods: ['decrement', 'increment']
})
useEffect(() => {
if(!wallet.isSignedIn()) wallet.requestSignIn();
}, []);
if(!wallet.isSignedIn()) return null;
return <h1>{wallet.getAccountId()}</h1>;
}