|
| 1 | +[//]: # `{ "title": "@mintbase-js/react", "order": "3" }` |
| 2 | + |
| 3 | +# @mintbase-js/react |
| 4 | + |
| 5 | +This package contains React helpers for interacting with Mintbase JS. |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | + |
| 9 | +<img src='https://img.shields.io/npm/dw/@mintbase-js/react' /> |
| 10 | + |
| 11 | +<img src='https://img.shields.io/bundlephobia/min/@mintbase-js/react'> |
| 12 | + |
| 13 | +</p> |
| 14 | + |
| 15 | +Example: |
| 16 | +You can check a [quick example of Simple Login](https://github.com/Mintbase/examples/tree/main/starter) using Next.js 14 and @mintbase-js/react |
| 17 | + |
| 18 | + |
| 19 | +[Check our Templates repository for Mintbase.js](https://github.com/Mintbase/templates) |
| 20 | + |
| 21 | +[Live Demo](https://starter.mintbase.xyz/) |
| 22 | + |
| 23 | +## Summary |
| 24 | + |
| 25 | +- [Installing](#Installing) |
| 26 | + |
| 27 | +- [BitteWalletContextProvider (default)](#bittewalletcontextprovider) : The default Bitte Wallet provider |
| 28 | + |
| 29 | + |
| 30 | +# Installing |
| 31 | + |
| 32 | +`@mintbase-js/react relies on React and React Dom version v18.2.0 due to @near-wallet-selector/modal-ui` |
| 33 | + |
| 34 | +### NPM: |
| 35 | + |
| 36 | +``` |
| 37 | +npm install @mintbase-js/react |
| 38 | +npm install @near-wallet-selector/modal-ui |
| 39 | +``` |
| 40 | + |
| 41 | +### Yarn: |
| 42 | + |
| 43 | +``` |
| 44 | +yarn add @mintbase-js/react |
| 45 | +yarn add @near-wallet-selector/modal-ui |
| 46 | +``` |
| 47 | + |
| 48 | +### PNPM: |
| 49 | + |
| 50 | +``` |
| 51 | +pnpm install @mintbase-js/react |
| 52 | +pnpm install @near-wallet-selector/modal-ui |
| 53 | +``` |
| 54 | + |
| 55 | +# BitteWalletContextProvider |
| 56 | + |
| 57 | +the default way of interacting with Mintbase Wallet is using the BitteWalletContextProvider |
| 58 | + |
| 59 | +{% code title="app.tsx" overflow="wrap" lineNumbers="true" %} |
| 60 | + |
| 61 | +## properties: |
| 62 | + |
| 63 | +**contractAddress** (optional): `If you set this it will connect the user using Limited Access Keys, set with your near contract address / your mintbase store address` |
| 64 | + |
| 65 | +**network** : ` mainnet | testnet` |
| 66 | + |
| 67 | +**callbackUrl** : `a valid https/http address to the user be sent after the transaction` |
| 68 | + |
| 69 | +**onlyMbWallet** : `boolean, it sets up only MintbaseWallet or if false(default) MintbaseWallet + default wallets` |
| 70 | + |
| 71 | +**additionalWallets** : `WalletModuleFactory[] extra wallets setup` |
| 72 | + |
| 73 | +```typescript |
| 74 | +import "@near-wallet-selector/modal-ui/styles.css"; |
| 75 | +import { BitteWalletContextProvider } from '@mintbase-js/react' |
| 76 | + |
| 77 | +<BitteWalletContextProvider |
| 78 | + contractAddress="mycontract.mintbase1.near" |
| 79 | + network="mainnet" |
| 80 | + callbackUrl="https://www.mywebsite.com/callback" |
| 81 | +> |
| 82 | + <Component {...pageProps} /> |
| 83 | +</BitteWalletContextProvider> |
| 84 | + |
| 85 | +``` |
| 86 | + |
| 87 | +# Troubleshooting |
| 88 | +The wallet runs only on client-side. |
| 89 | + |
| 90 | +Any other questions or issues you can contact support on our [Telegram Channel](https://telegram.me/mintdev). |
| 91 | + |
| 92 | + |
| 93 | +## License |
| 94 | + |
| 95 | +This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0). |
0 commit comments