https://github.com/brandonpittman/remix-fathom
React Hook to use Fathom in Remix.
https://github.com/brandonpittman/remix-fathom
fathom fathom-analytics hook react remix remix-run typescript
Last synced: 3 months ago
JSON representation
React Hook to use Fathom in Remix.
- Host: GitHub
- URL: https://github.com/brandonpittman/remix-fathom
- Owner: brandonpittman
- Created: 2022-04-07T07:06:36.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-08T14:37:02.000Z (over 3 years ago)
- Last Synced: 2025-10-06T22:54:08.398Z (9 months ago)
- Topics: fathom, fathom-analytics, hook, react, remix, remix-run, typescript
- Language: TypeScript
- Homepage:
- Size: 368 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# remix-fathom
This package exports the following hooks:
- `useFathom(id, opts)`
- `useGoal(code, cents)`
## Setup
```sh
npm install remix-fathom fathom-client
```
`fathom-client` is a peer dependency.
Then in `app/root.tsx`, add
```tsx
import { useFathom } from "remix-fathom";
useFathom("YOUR_SITE_ID", myOpts);
```
## useFathom
Supply your Fathom site ID and optional opts object to configure [fathom-client][]. While fathom-client is a peer dependency, the `useFathom` hook will set up loading and registering your tracked views each time the page changes.
## useGoal
This hook returns you a memoized function pre-populated with your provided code and cents.
---
Thanks to Sergio Xalambrà for the [inspiration][]!
[inspiration]: https://sergiodxa.com/articles/use-fathom-with-remix
[fathom-client]: https://www.npmjs.com/package/fathom-client