npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mirohq/websdk-react-hooks

v0.0.3

Published

Collection of React Hooks wrappers for Miro WebSDK

Downloads

99

Readme

miro-websdk-react-hooks NPM version

Collection of React hooks to interact with Miro Platform WebSDK.

Add a bit of :sparkles:reactivity:sparkles: to your Miro app.

Use it!

$ npm install @mirohq/websdk-react-hooks
// or
$ yarn add @mirohq/websdk-react-hooks

Inject Miro instance

Wrap your components with MiroProvider and inject the global instance of Miro WebSDK.

import { MiroProvider } from "@mirohq/websdk-react-hooks";

const App: React.FC = ({ children }) => <MiroProvider>{children}</MiroProvider>;

/*
 You can also optional inject the global Miro WebSDK instance
 
 const App: React.FC = ({ children }) => <MiroProvider miro={window.miro}>{children}</MiroProvider>;
*/

Make sure you have a Miro application configured to use it. The hooks in this library will only work within Miro boards and in a well-configured app.

Isomorphic or not?

The Miro WebSDK is NOT isomorphic, meaning that you cannot use it in both server and client environments. This also applies to this library, it won't work wehn you are rendereing your React components in the server.

What if I am using Nextjs?

Using app router

Just make sure that the component that uses the hooks is only rendered on the client by using the use client directive on top of your component.

'use client'
import { useCurrentUser } from "@mirohq/websdk-react-hooks";

// Your component

Using pages router

Wrap your component in a dynamic code block that will defer the component rendering to only execute in the client-side:

import dynamic from "next/dynamic";
import React from "react";
import { useCurrentUser } from "@mirohq/websdk-react-hooks";

const NoSsr: React.FC<React.PropsWithChildren> = (props) => (
  <React.Fragment>{props.children}</React.Fragment>
);

const NoSSRWrapper = dynamic(() => Promise.resolve(NoSsr), {
  ssr: false,
});

// And in your Nextjs page

const Component: React.FC = () => {
    const { status, result, error } = useCurrentUser();

    if (status === "success") {
        return <p>The current user is "{result?.name}"</p>;
    }
}

export default function OnlyInTheClient() {
  return (
    <NoSSRWrapper>
      <Group />
    </NoSSRWrapper>
  );
}

Built with

This library is heavily inspired on https://github.com/react-hookz/web. Pure :sparkling_heart: awesomeness :sparkling_heart:.

Contributing

Please refer to the CONTRIBUTING.md guide to get started.

Hooks