use-lanyard

React hook for Lanyard for tracking your Discord presence.

Usage no npm install needed!

<script type="module">
  import useLanyard from 'https://cdn.skypack.dev/use-lanyard';
</script>

README

use-lanyard

View Demo

React hook for lanyard, an easy way to track your Discord presence through REST or websockets.

It's easy to use and fully typed. It returns an swr responseInterface, but if you don't know what that means, here's an example:

import {useLanyard} from 'use-lanyard';

const DISCORD_ID = '268798547439255572';

export function Activity() {
    const {data: activity} = useLanyard(DISCORD_ID);

    return <>...</>;
}

Socket

There is also a hook for using the websocket that Lanyard provides, here's an example:

import {useLanyardWs} from 'use-lanyard';

const DISCORD_ID = '268798547439255572';

export function Activity() {
    const activity = useLanyardWs(DISCORD_ID);

    return <>...</>;
}

Types

You can also import the named types as follows

import { Data, Activity, ...etc } from 'use-lanyard';
// See src/types.ts for all types

Acknowledgements