- Home
- Skills
- Near
- Agent Skills
- Near Connect Hooks
near-connect-hooks_skill
5
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill near/agent-skills --skill near-connect-hooks- SKILL.md4.7 KB
Overview
This skill provides React hooks to integrate NEAR Protocol wallets into React and Next.js apps using @hot-labs/near-connect. It exposes a NearProvider and a useNearWallet hook to handle authentication, view/call contract methods, transfers, access key management, and NEP-413 message signing. The hooks simplify common wallet flows while allowing low-level transaction control when needed.
How this skill works
Wrap your app with NearProvider to configure network and RPC endpoints. useNearWallet returns the connected account, loading state, RPC provider and connector, and a set of helpers for signIn/signOut, viewFunction, callFunction, transfer, access key operations, and NEP-413 signing. Advanced functions expose transaction builders and Actions for composing single or batched transactions and signing/sending them through the wallet.
When to use it
- Building React or Next.js dApps that require NEAR wallet authentication
- Calling view or change methods on NEAR smart contracts from the UI
- Sending NEAR token transfers or managing allowances programmatically
- Adding access-key-based UX for restricted contract operations
- Implementing NEP-413 message signing or low-level transaction flows
Best practices
- Wrap the entire app (or top-level layout) with NearProvider to ensure hooks initialize correctly
- Check loading and signedAccountId before rendering wallet-dependent UI to avoid flashes
- Use viewFunction for read-only calls and callFunction for state changes with sensible gas/deposit defaults
- Prefer action builders (Actions) for complex transactions to reduce manual error
- Use getBalance and getAccessKeyList to present accurate account state and to decide when to add/delete keys
Example use cases
- Add a Connect/Disconnect button that calls signIn and signOut and shows signedAccountId
- Fetch and display contract state with viewFunction and refresh after a callFunction mutation
- Send a one-off NEAR transfer using transfer with yoctoNEAR amounts
- Create temporary function-call access keys for third-party integrations via addFunctionCallKey and revoke with deleteKey
- Sign a NEP-413 message to verify wallet ownership during external onboarding
FAQ
Yes. near-api-js is a peer dependency used under the hood for RPC and transaction primitives, so install it alongside near-connect-hooks.
How do I configure testnet vs mainnet?
Pass network: 'testnet' or 'mainnet' to NearProvider config. You can also provide custom RPC endpoints per network via the providers config.