├── tsconfig.json ├── LICENSE ├── README.md ├── src └── index.ts ├── package.json ├── .gitignore └── pnpm-lock.yaml /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "esnext", 5 | "declaration": true, 6 | "declarationDir": "dist", 7 | "preserveSymlinks": true, 8 | "outDir": "dist", 9 | "isolatedModules": true, 10 | "esModuleInterop": true, 11 | "downlevelIteration": true, 12 | "noImplicitAny": false, 13 | "noUnusedParameters": true, 14 | "preserveConstEnums": true, 15 | "skipLibCheck": true, 16 | "moduleResolution": "Node", 17 | "forceConsistentCasingInFileNames": true, 18 | "allowSyntheticDefaultImports": true, 19 | "allowJs": true 20 | }, 21 | "exclude": ["node_modules"], 22 | "include": ["src"] 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 v 1 r t l 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # use-ens 2 | 3 | A React hook to fetch ENS records from a domain. 4 | 5 | ## Install 6 | 7 | ```sh 8 | pnpm i use-ens 9 | ``` 10 | 11 | ## Example 12 | 13 | [![CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/useens-demo-q566k) 14 | 15 | ```jsx 16 | import React, { useEffect } from 'react' 17 | import { useWeb3React } from '@web3-react/core' 18 | import { useENS } from 'use-ens' 19 | 20 | const App = () => { 21 | const { provider, activate } = useWeb3React() 22 | 23 | useEffect(() => { 24 | injected.isAuthorized().then((isAuth) => { 25 | if (isAuth) activate(injected) 26 | }) 27 | }, []) 28 | 29 | const { address, records } = useENS(provider, 'dame.eth') 30 | 31 | return ( 32 | <> 33 |

Address: {address ? address : ''}

34 |

ENS Records

35 | 42 | {!active &&