Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brickpop/use-url-hash

A React hook to provide the upddated hash of the current URL
https://github.com/brickpop/use-url-hash

Last synced: 11 days ago
JSON representation

A React hook to provide the upddated hash of the current URL

Awesome Lists containing this project

README

        

# Use URL Hash

A simple React hook providing the current URL hash and triggering a re-render on every change.

## Get started

Install the package:

```bash
npm i use-url-hash
```

Import it in your component:

```tsx
import React from 'react'
import { useUrlHash } from "use-url-hash"

const MyApp = () => {
const hash = useUrlHash()

return (


Use URL Hash


The current URL hash is "{hash}"



)
}
```

The value of `hash` will be already set at the very first render.

## Example

Check out `example/index.tsx` for a working example.

```bash
cd example
npm install
npm start
```