https://github.com/electerious/use-ackee
Use Ackee in React.
https://github.com/electerious/use-ackee
Last synced: about 1 year ago
JSON representation
Use Ackee in React.
- Host: GitHub
- URL: https://github.com/electerious/use-ackee
- Owner: electerious
- License: mit
- Created: 2019-11-10T13:20:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-08T13:32:33.000Z (over 1 year ago)
- Last Synced: 2025-04-03T03:11:09.548Z (about 1 year ago)
- Language: JavaScript
- Size: 392 KB
- Stars: 24
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-github-projects - use-ackee - Use Ackee in React. ⭐26 `JavaScript` ⚡ (🌐 Web Development - Frontend)
README
# use-ackee
 [](https://coveralls.io/github/electerious/use-ackee?branch=master)
Use [Ackee](https://github.com/electerious/Ackee) in React.
## Install
```
npm install use-ackee
```
*or*
```
yarn add use-ackee
```
## Usage
Import and call `use-ackee` in a component responsible for the routing or inside your routes. Make sure that only one `use-ackee` hook is actively rendered to avoid redundant records.
```js
useAckee('/current/path', {
server: 'https://example.com',
domainId: 'hd11f820-68a1-11e6-8047-79c0c2d9bce0'
}, {
detailed: false,
ignoreLocalhost: true,
ignoreOwnVisits: true
})
```
Ackee will create a new record every time the `pathname` changes. An undefined or empty `pathname` will be skipped. Use `/` for the root instead.
This hook is a no-op on the server for safe usage during server-side rendering.
## API
### Parameters
- `pathname` `{?String}` Current path.
- `environment` `{Object}` An object that contains details about your [Ackee](https://github.com/electerious/Ackee) installation. The `server` property must not end with a slash.
- `opts` `{?Object}` An object of [Ackee options](https://github.com/electerious/ackee-tracker#options).
## Examples
- [React Router](demos/react-router/README.md)