<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andika Tech on Medium]]></title>
        <description><![CDATA[Stories by Andika Tech on Medium]]></description>
        <link>https://medium.com/@andika.techwrite?source=rss-2dec45978567------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6czgWbtLP2H5DncDd72QUA.png</url>
            <title>Stories by Andika Tech on Medium</title>
            <link>https://medium.com/@andika.techwrite?source=rss-2dec45978567------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:43:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andika.techwrite/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Developer’s Intro to Huddle01 SDK and Ideas to Build]]></title>
            <link>https://medium.com/@andika.techwrite/a-developers-intro-to-huddle01-sdk-and-ideas-to-build-802bcf6c58d7?source=rss-2dec45978567------2</link>
            <guid isPermaLink="false">https://medium.com/p/802bcf6c58d7</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[huddle01]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[real-time-communication]]></category>
            <dc:creator><![CDATA[Andika Tech]]></dc:creator>
            <pubDate>Thu, 30 May 2024 17:58:04 GMT</pubDate>
            <atom:updated>2024-06-01T11:14:21.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v4i_W6IzRc7DCzXZ" /></figure><p>Tech companies and developers building products around real-time communication often need more scalability and security while reducing costs. <a href="https://app.huddle01.com/"><strong>Hudde01</strong></a> emerges as a pioneer in the decentralized physical network dedicated to making real-time communication faster, cheaper and more secure. Huddle01 is designed to provide ultra-low latency, enhanced data privacy and up to 95% cost savings on data transfer and computing.</p><p>To make Huddle01 technology more accessible to web2 and web3 developers, it is wrapped in SDKs. This way, it is possible to integrate Huddle01 into a project with fewer codes. This article aims to introduce the Huddle01 SDK — its features, benefits and how it empowers developers to build next-generation communication applications. This article also includes use cases and ideas you can build leveraging the Huddle01 SDK.</p><h4>Prerequisites</h4><p>Before diving into the Huddle01 SDK, ensure you have the following:</p><ul><li>Basic programming knowledge (including Reactjs)</li><li>A text editor (VS code)</li></ul><h4>Understanding Basic Concepts</h4><p>Before we explore the coding intricacies of Huddle01 SDK, some basic concepts need to be understood.</p><ul><li><strong>Room</strong>: A room is an entity within Huddle01 where you can have your meeting sessions. It acts like a container that holds all the participants and their audio/video streams during a meeting. Each room has a unique identifier called a <strong>roomID</strong>. Think of it like a conference room that can be used for multiple meeting sessions, but only one meeting can happen at a time within the room.</li><li><strong>Peer: </strong>A peer represents a participant inside a room. It is an object containing a participant&#39;s media (video and audio) streams. The peer is anonymous to an individual attending a meeting in a conference room.</li><li><strong>MediaStream: </strong>A MediaStream interface represents live feeds of audio and video content from a participant (peer) during a meeting. A stream can consist of several tracks of video and audio content.</li><li><strong>MediaStreamTrack:</strong> The MediaStreamTrack represents a single audio or video track within the MediaStream.</li><li><strong>Local:</strong> When you join a room, you become a <strong>peer</strong>. The <strong>local </strong>represents all operations related to you (peer object) inside the room.</li><li><strong>Remote</strong>: The remote represents all other participants in a room. It follows the same convention as the local keyword. For instance, other participants’ audio and video streams are referred to as remoteAudio and remoteVideo respectively.</li><li><strong>Data Message</strong>: Peers in a room can send messages to one another — text not exceeding 280 characters in length. These messages are stored as data messages.</li><li><strong>Metadata</strong>: Metadata are generic objects attached to both Peer and Room. They are used to store additional information about the related peer or room.</li><li><strong>Room states</strong>: A room can be in idle, connecting, connected, failed or closed state depending on Peers activities.</li></ul><p>Huddle01 provides developers with scalable and customizable SDK for web and mobile applications. Huddle01 SDK is available for multiple platforms — <a href="https://docs.huddle01.com/docs/Javascript"><strong>Javascript</strong></a>, <a href="https://docs.huddle01.com/docs/React"><strong>Reactjs</strong></a>, <a href="https://docs.huddle01.com/docs/React-Native"><strong>React-Native</strong></a>, <a href="https://docs.huddle01.com/docs/Flutter/quickstart"><strong>Flutter</strong></a> and <a href="https://docs.huddle01.com/docs/Server-SDK"><strong>Server-SDK</strong></a>. Building a video-conferencing platform or any real-time communication app is now easy with Huddle01 SDK. In this article, we will create an app that allows users to host audio and video spaces, with features such as recording, livestreaming and custom authentication.</p><h4>Get started with Nextjs and Huddle01 SDK</h4><p>To get started, we need to install Nextjs and setup Huddle01 SDK</p><ul><li>On your terminal, run the command below to install <a href="https://nextjs.org/docs/getting-started/installation"><strong>Nextjs</strong></a>. For this tutorial, the app directory is used (check <a href="https://nextjs.org/docs/getting-started/project-structure"><strong>Nextjs doc</strong></a><strong> </strong>for more info):</li></ul><pre>npx create-next-app@latest</pre><ul><li>Navigate to your Nextjs app to install the necessary dependencies including the Huddle01 SDK and spin up the app on localhost:</li></ul><pre>npm install @huddle01/react @huddle01/server-sdk axios<br>npm run dev</pre><ul><li>The next step is to get our API keys from Huddle01. Go to <a href="https://docs.huddle01.com/docs/api-keys"><strong>https://docs.huddle01.com/docs/api-keys</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*LurrVNl5rdi3Fe38AnBH8g.png" /></figure><ul><li>Click the ‘Connect Wallet’ button and connect your Ethereum wallet to the Huddle01 site. Once connected, enter your project name and your email to get your credentials.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*YRALmXXXSjhdE8i7-0vSFg.png" /></figure><figure><img alt="Your API key and Project ID" src="https://cdn-images-1.medium.com/max/758/1*t532_WAVuvSvv4iPGgdpUQ.png" /></figure><ul><li>Create an .env file in the root directory of your folder and add the API key and project ID.</li></ul><pre>API_KEY=YOUR_API_KEY<br>PROJECT_ID=YOUR_PROJECT_ID</pre><ul><li>The next step is to add Huddle01 provider to our app to access the functions and components of Huddle01 SDK globally. Add the following code to the layout.tsx file.</li></ul><pre>&quot;use client&quot;;<br>import { HuddleClient, HuddleProvider } from &quot;@huddle01/react&quot;;<br><br>export default function RootLayout({<br>  children,<br>}: Readonly&lt;{<br>  children: React.ReactNode;<br>}&gt;) {<br>  const huddleClient = new HuddleClient({<br>    projectId: process.env.HUDDLE_PROJECT_ID!,<br>  });<br><br>  return (<br>    &lt;html lang=&#39;en&#39;&gt;<br>      &lt;body&gt;<br>        &lt;HuddleProvider client={huddleClient}&gt;{children}&lt;/HuddleProvider&gt;<br>      &lt;/body&gt;<br>    &lt;/html&gt;<br>  );<br>}</pre><h4>Room and Token Generation</h4><p>After setting up our Nextjs app, we create a server-side component that initializes a Room and an API endpoint for generating access tokens.</p><ul><li>Create a ts file, you can call it createRoom.ts and add the following code:</li></ul><pre>&quot;use server&quot;;<br> <br>export const createRoom = async () =&gt; {<br>  const response = await fetch(&quot;https://api.huddle01.com/api/v1/create-room&quot;, {<br>    method: &quot;POST&quot;,<br>    body: JSON.stringify({<br>      title: &quot;Huddle01 Room&quot;,<br>    }),<br>    headers: {<br>      &quot;Content-type&quot;: &quot;application/json&quot;,<br>      &quot;x-api-key&quot;: process.env.API_KEY!,<br>    },<br>    cache: &quot;no-cache&quot;,<br>  });<br> <br>  const data = await response.json();<br>  const roomId:string = data.data.roomId;<br>  return roomId;<br>};</pre><p>Here we are calling an API endpoint to create a Room. The roomID is returned from the API call.</p><ul><li>Create an API to generate an access token. Create the /api folder and create the token folder inside of it. Then, create a route.ts file in the token folder to tell the browser it’s an API endpoint. Add the following code:</li></ul><pre>import { AccessToken, Role } from &quot;@huddle01/server-sdk/auth&quot;;<br> <br>export const dynamic = &quot;force-dynamic&quot;;<br> <br>export async function GET(request: Request) {<br>  const { searchParams } = new URL(request.url);<br> <br>  const roomId = searchParams.get(&quot;roomId&quot;);<br> <br>  if (!roomId) {<br>    return new Response(&quot;Missing roomId&quot;, { status: 400 });<br>  }<br> <br>  const accessToken = new AccessToken({<br>    apiKey: process.env.API_KEY!,<br>    roomId: roomId as string,<br>    role: Role.HOST,<br>    permissions: {<br>      admin: true,<br>      canConsume: true,<br>      canProduce: true,<br>      canProduceSources: {<br>        cam: true,<br>        mic: true,<br>        screen: true,<br>      },<br>      canRecvData: true,<br>      canSendData: true,<br>      canUpdateMetadata: true,<br>    }<br>  });<br> <br>  const token = await accessToken.toJwt();<br> <br>  return new Response(token, { status: 200 });<br>}</pre><p>We made a GET request with the roomID passed as a parameter. Using the AccessToken component provided by Huddle01 SDK, we can generate an access token based on the roomID. When this endpoint is called, it returns the access token.</p><h4>Creating a User Interface to manage a Room</h4><p>We might have to skip the styling but I will provide the link to the GitHub repo at the end of the article. This is to focus more on building the core features of the app. In the page.tsx of the homepage, add the following code:</p><pre>&quot;use client&quot;;<br><br>import { useRoom } from &quot;@huddle01/react/hooks&quot;;<br>import { createRoom } from &quot;./createRoom&quot;;<br>import { useEffect, useState } from &quot;react&quot;;<br>import axios from &quot;axios&quot;;<br><br><br><br>const App = () =&gt; {<br>  const [roomId, setRoomId] = useState&lt;string&gt;();<br>  const [token, setToken] = useState&lt;string&gt;();<br><br>  useEffect(() =&gt; {<br>    // Creating RoomId<br>    createRoom().then((roomId) =&gt; {<br>      setRoomId(roomId);<br>    });<br><br>    // Creating token from the roomId<br>    const fetchToken = async () =&gt; {<br>      const res = await axios.get(`/api/token?roomId=${roomId}`);<br>      return res.data;<br>    };<br>    roomId &amp;&amp; fetchToken().then((res) =&gt; {<br>      setToken(res);<br>    });<br>  }, []);<br><br>  // To join or leave room<br>  const { joinRoom, leaveRoom } = useRoom({<br>    onJoin: () =&gt; {<br>      console.log(&quot;Joined the room&quot;);<br>    },<br>    onLeave: () =&gt; {<br>      console.log(&quot;Left the room&quot;);<br>    },<br>  });<br><br>  return (<br>    &lt;div&gt;<br>      {/* Buttons to join or leave a room */}<br>      &lt;div&gt;<br>      &lt;button<br>        onClick={async () =&gt; {<br>          await joinRoom({<br>            roomId: roomId as string,<br>            token: token!,<br>          });<br>        }}&gt;<br>        Join Room<br>      &lt;/button&gt;<br>      &lt;button onClick={leaveRoom}&gt;Leave Room&lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default App;</pre><p>We created a state to handle the room ID and called the createRoom() function in a useEffect to generate a room ID. The useRoom hook from Huddle01 SDK makes it possible to join a Room with roomId and token as parameters. The token is generated by calling the API — /api/token we created. The joinRoom and leaveRoom functions in the onClick event listeners will allow users to join or leave the room using the buttons</p><p><em>NB: We can also allow users to input the room ID if they have one.</em></p><ul><li>Enable and display video, audio and screen shares.</li></ul><pre>&quot;use client&quot;;<br><br>import { useRoom } from &quot;@huddle01/react/hooks&quot;;<br>import { createRoom } from &quot;./createRoom&quot;;<br>import { useEffect, useState } from &quot;react&quot;;<br>import { Audio, Video } from &#39;@huddle01/react/components&#39;;<br>import axios from &quot;axios&quot;;<br>import {<br>  useLocalVideo,<br>  useLocalAudio,<br>  useLocalScreenShare,<br>} from &quot;@huddle01/react/hooks&quot;;<br><br>const App = () =&gt; {<br>  const [roomId, setRoomId] = useState&lt;string&gt;();<br>  const [token, setToken] = useState&lt;string&gt;();<br><br>  const {<br>    stream: videoStream,<br>    enableVideo,<br>    disableVideo,<br>    isVideoOn<br>  } = useLocalVideo();<br><br>  const {<br>    stream: audioStream,<br>    enableAudio,<br>    disableAudio,<br>    isAudioOn,<br>  } = useLocalAudio();<br><br>  const { startScreenShare, stopScreenShare, shareStream } =<br>    useLocalScreenShare();<br><br>  useEffect(() =&gt; {<br>    // Creating RoomId<br>    createRoom().then((roomId) =&gt; {<br>      setRoomId(roomId);<br>      console.log(roomId);<br>    });<br><br>    // Creating token from the roomId<br>      const fetchToken = async () =&gt; {<br>      const res = await axios.get(`/api/token?roomId=${roomId}`);<br>      return res.data;<br>    };<br>    roomId &amp;&amp; fetchToken().then((res) =&gt; {<br>      setToken(res);<br>    });<br>  }, []);<br><br>  // To join or leave room<br>  const { joinRoom, leaveRoom } = useRoom({<br>    onJoin: () =&gt; {<br>      console.log(&quot;Joined the room&quot;);<br>    },<br>    onLeave: () =&gt; {<br>      console.log(&quot;Left the room&quot;);<br>    },<br>  });<br><br>  return (<br>    &lt;div&gt;<br>      {/* Buttons to join or leave a room */}<br>      &lt;div&gt;<br>      &lt;button<br>        onClick={async () =&gt; {<br>          await joinRoom({<br>            roomId: roomId as string,<br>            token: token!,<br>          });<br>        }}&gt;<br>        Join Room<br>      &lt;/button&gt;<br>      &lt;button onClick={leaveRoom}&gt;Leave Room&lt;/button&gt;<br>      &lt;/div&gt;<br><br>      {/* Buttons to toggle webcam, mic and screen share */}<br>      &lt;div&gt;<br>        {/* Webcam */} <br>        &lt;button <br>          onClick={() =&gt; {<br>            isVideoOn ? disableVideo() : enableVideo()<br>          }}&gt;<br>          Fetch and Produce Video Stream<br>        &lt;/button&gt;<br> <br>        {/* Mic */} <br>       &lt;button <br>          onClick={() =&gt; {<br>            isAudioOn ? disableAudio() : enableAudio();<br>          }}&gt;<br>          Fetch and Produce Audio Stream<br>        &lt;/button&gt;<br> <br>        {/* Screen Share */}<br>        &lt;button <br>          onClick={() =&gt; {<br>            shareStream ? stopScreenShare() : startScreenShare();<br>          }}&gt;<br>          Fetch and Produce Screen Share Stream<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br><br>      {/* Show your video and audio*/}<br>      &lt;div&gt;<br>     {audioStream &amp;&amp; &lt;Audio stream={audioStream}/&gt;} <br>     {videoStream &amp;&amp; &lt;Video stream={videoStream}/&gt;} <br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default App;</pre><p>The Huddle01 SDK has useLocalVideo, useLocalAudio, useLocalScreenShare hooks which makes it possible to toggle users’ microphones, webcam and screen sharing — in this case, using buttons. The Audio and Video are components of Huddle01 SDK to display users’ video and audio streams.</p><ul><li>Allow users to view other peers’ audio, video and screen share</li></ul><p>To allow users to view peers’ audio and video streams including screen share, we create a component showPeer.tsx</p><pre>import { <br>    usePeerIds, <br>    useRemoteVideo, <br>    useRemoteAudio, <br>    useRemoteScreenShare <br>  } from &#39;@huddle01/react/hooks&#39;;<br>  import { Audio, Video } from &#39;@huddle01/react/components&#39;;<br>  import { Role } from &#39;@huddle01/server-sdk/auth&#39;;<br>  import { FC } from &#39;react&#39;;<br>   <br>  interface RemotePeerProps {<br>    peerId: string;<br>  }<br>   <br>  const RemotePeer: FC&lt;RemotePeerProps&gt; = ({ peerId }) =&gt; {<br>    <br>    const { stream: videoStream } = useRemoteVideo({ peerId });<br>    const { stream: audioStream } = useRemoteAudio({ peerId });<br>    const { videoStream: screenVideoStream, audioStream: screenAudioStream } = useRemoteScreenShare({ peerId });<br>   <br>    return (<br>      &lt;div&gt;<br>        {videoStream &amp;&amp; &lt;Video stream={videoStream}/&gt;}<br>        {audioStream &amp;&amp; &lt;Audio stream={audioStream}/&gt;}<br>        {screenVideoStream &amp;&amp; &lt;Video stream={screenVideoStream}/&gt;}<br>        {screenAudioStream &amp;&amp; &lt;Audio stream={screenAudioStream}/&gt;}<br>      &lt;/div&gt;<br>    ) <br>  }<br>   <br>  const ShowPeers = () =&gt; {<br>    const { peerIds } = usePeerIds({ roles: [Role.HOST, Role.CO_HOST] }); // Get Hosts And Cohost&#39;s peerIds<br>   <br>    return (<br>      &lt;div&gt;<br>        {peerIds.map(peerId =&gt; {<br>          return &lt;RemotePeer peerId={peerId}  /&gt;<br>        })}<br>      &lt;/div&gt;<br>    )<br>  }<br>   <br>  export default ShowPeers;</pre><p>The useRemoteVideo, useRemoteAudio and useRemoteScreenShare exposes the audio and video streams of other peers in the room, including their screen shares.</p><ul><li>Add the ShowPeers component to page.tsx</li></ul><pre> import ShowPeers from &quot;./components/showPeers&quot;;<br><br>//Add this to the return section of the function<br>return(<br> &lt;div&gt;<br> &lt;ShowPeers/&gt;<br> &lt;/div&gt;<br><br>)</pre><p>So far, users can join a room and connect with other peers in the room. We can expand the app by adding recording functionality.</p><h4>Recording functionalities</h4><p>Huddle01 SDK has the Record class with functions that allow us to record and live stream meetings. To record meetings;</p><ul><li>Create an API route to start recording. In your /api folder, create a new folder, /record. Inside the record folder, we will have /start and /stop folders. Create a route.ts file in both folders. These folders will contain code to start and stop recording. In /api/record/start/route.ts, add the following code:</li></ul><pre>import type { NextApiRequest, NextApiResponse } from &#39;next&#39;;<br>import { Recorder } from &#39;@huddle01/server-sdk/recorder&#39;;<br>import axios from &quot;axios&quot;;<br> <br>export default async function handler(<br>  req: NextApiRequest,<br>  res: NextApiResponse<br>) {<br>  const { roomId } = req.query;<br> <br>  //checking for project credentials<br>  if (!process.env.PROJECT_ID &amp;&amp; !process.env.API_KEY) {<br>    return res<br>      .status(400)<br>      .json({ error: &#39;PROJECT_ID and API_KEY are required&#39; });<br>  }<br> <br>  //creating the Recorder class instance<br>  const recorder = new Recorder(<br>    process.env.PROJECT_ID!,<br>    process.env.API_KEY!<br>  );<br> <br>  //generating an access token for the recorder<br>  const accessTokenAPI = await axios.get(`/token?roomId=${roomId}`);<br>  const accessToken = acessTokenAPI.data<br>      <br>  //starting the recording<br>  const recording = await recorder.startRecording({<br>    roomId: roomId as string,<br>    token: accessToken,<br>  });<br> <br>  return res.status(200).json({ recording });<br>}</pre><ul><li>In the /api/record/stop/route.ts, add the following code to stop recordings:</li></ul><pre>import type { NextApiRequest, NextApiResponse } from &#39;next&#39;;<br>import { Recorder } from &#39;@huddle01/server-sdk/recorder&#39;;<br> <br>interface Recordings {<br>  id: string;<br>  recordingUrl: string;<br>  recordingSize: number;<br>}<br> <br>export default async function handler(<br>  req: NextApiRequest,<br>  res: NextApiResponse<br>) {<br>  const { roomId } = req.query;<br> <br>  //checking for project credentials<br>  if (!process.env.PROJECT_ID &amp;&amp; !process.env.API_KEY) {<br>    return res<br>      .status(400)<br>      .json({ error: &#39;PROJECT_ID and API_KEY are required&#39; });<br>  }<br> <br>  //creating the Recorder class instance<br>  const recorder = new Recorder(<br>    process.env.PROJECT_ID!,<br>    process.env.API_KEY!<br>  );<br> <br>  //stopping the recording<br>  const recording = await recorder.stop({<br>    roomId: roomId as string,<br>  });<br> <br>  const { msg } = recording;<br> <br>  if (msg === &#39;Stopped&#39;) {<br> <br>    //fetching the recording<br>    const response = await fetch(<br>      &#39;https://api.huddle01.com/api/v1/get-recordings&#39;,<br>      {<br>        headers: {<br>          &#39;x-api-key&#39;: process.env.API_KEY!,<br>        },<br>      }<br>    );<br>    const data = await response.json();<br> <br>    const { recordings } = data as { recordings: Recordings[] };<br> <br>    //return the most recent recording from the list<br>    return res.status(200).json({ recording: recordings[0] });<br>  }<br> <br>  return res.status(200).json({ recording });<br>}</pre><ul><li>The next step is to call these two APIs we created on the client side. On our page.tsx, we add a button to start and stop recordings.</li></ul><pre>  const [isRecording, setIsRecording] = useState&lt;boolean&gt;(false);<br> <br>  return (<br>    &lt;button<br>        onClick={async () =&gt; {<br>            const status = isRecording<br>            ? await axios.get(<br>                `/api/stopRecording?roomId=${roomId}`<br>                )<br>            : await axios.get(<br>                `/api/startRecording?roomId=${roomId}`<br>                );<br> <br>            const data = await status.data;<br> <br>            if(isRecording) {<br>                console.log(&quot;Recording Stopped&quot;, { data });<br>            } else {<br>                console.log(&quot;Recording Started&quot;, { data });<br>            }<br>            setIsRecording(!isRecording);<br>        }}<br>    &gt;<br>        {isRecording ? &quot;Stop Recording&quot; : &quot;Start Recording&quot;}<br>    &lt;/button&gt;<br>  )</pre><h4>The result:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKVw6p--UbJFXNciluluvg.png" /></figure><p>So far, we have implemented these with just a few lines of code. You can check out a sample app built by Huddle01’s team <a href="https://github.com/Huddle01/client-next-ts-example"><strong>here</strong></a><strong>.</strong> This is just the basic thing we can do with Huddle01 SDK. We can improve further on our app by adding;</p><ul><li>Live-streaming functionality (<a href="https://docs.huddle01.com/docs/guides/recording-livestreaming"><strong>check the guide here</strong></a>)</li><li>We can add a collaborative whiteboard, where users can work together on a drawing tab while on the call (<a href="https://docs.huddle01.com/docs/guides/collaborative-whiteboard"><strong>check it out</strong></a>)</li><li>We can also add custom authentication for users to join the meeting</li><li>It is also possible to make our app such that only users with a particular token or NFT in their wallets can attend the call.</li></ul><p>Aside from the ones mentioned above, there are endless possibilities for what you can do with Huddle01. Developers and companies have built awesome and ground-breaking apps with Huddle01. Some of them include</p><ol><li><strong>Meetwithwallet</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXxCjAxkAqa7K-kwA71RLQ.png" /><figcaption>meetwithwallet</figcaption></figure><p><a href="https://meetwithwallet.xyz/"><strong>Meetwithwallet</strong></a> is a web3 app that allows users to schedule meetings with friends and colleagues using web3 wallets. Meetwithwallet outperforms web2 counterparts with enhanced privacy and security. This platform uses Huddle01 as part of its core technology.</p><p>2. <strong>Ethermail</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1SZqgbCDO2BSJufxyTBHyQ.png" /><figcaption>Ethermail</figcaption></figure><p><a href="https://ethermail.io/"><strong>Ethermail</strong></a> is a novel email solution in the web3 industry. Users can send emails securely (encrypted) and anonymously using their wallets. Ethermail records around 320 million emails per day.</p><p>3. <strong>SyncX</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OBpQT4BzI_wW89LGBQtLpw.png" /><figcaption>SyncX</figcaption></figure><p><a href="https://syncx.vercel.app/"><strong>SyncX</strong></a> is a product that enables influencers, motivators and consultants to manage and monetise all their interactions. Users can host one-on-one sessions and webinars and charge their customers a fee Matic — a Polygon token. Selling digital products is also possible with SyncX.</p><p>4. <strong>Blinkr</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M9pdVxpBiUWCGOh6xVPf8w.png" /><figcaption>Blinkr</figcaption></figure><p><a href="https://blinkr-five.vercel.app/"><strong>Blinkr</strong></a> allows people with the same NFTs to connect randomly. People with the same NFT often share similar interests and have things in common. Blinkr brings them together to connect and grow their network.</p><p>5. <strong>Peer Code</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsfAa8oxkkrWEF6K9FbLew.png" /><figcaption>Peercode</figcaption></figure><p><a href="https://peer-code.vercel.app/"><strong>Peer Code</strong></a> is also built using Huddle01’s web3 video infrastructure, it allows developers to collaborate on a project. Developers can connect to Peercode and communicate with one another while building their apps.</p><h4>Product ideas and other use cases that integrate Huddle01 Infrastructure</h4><p>While I’ve mentioned the apps that have been built with Huddle01 infrastructure, here are product ideas and use cases that you can build:</p><ul><li><strong>An Inclusive Education App</strong></li></ul><p>Some applications aim to bridge the gap in Web3 literacy. However,<strong> </strong>most of them have tutorials in texts, pre-recorded videos and discord chat rooms in case of a blocker while learning. You can create a platform that provides a personalised learning environment, where users can reach out to mentors in real-time while on the app. Tutors and mentors can easily hold meetings and give their lectures. Students can hop on a call with one another to solve a problem or work on an assignment together. All these I’ve mentioned can be built using leveraging Huddle01 technology.</p><ul><li><strong>Team Collaboration Platform For NFT Creators:</strong></li></ul><p>NFT creators often want to collaborate on a project to create NFTs for their community. Most of them end up using web2 apps like Zoom. You can create an app that solves this problem. Huddle01 makes it possible to collaborate on a drawing tool in a meeting. It’s a fantastic project you can pull off.</p><ul><li><strong>An App For Community Call</strong></li></ul><p>All web3 projects that are about to launch have one goal in common. The goal is to grow their community. One of their strategies is hosting community calls and rewarding attendees with exclusive NFTs and tokens. It would be brilliant if there is an app that can handle the meeting, and take the register of attendees (by collecting their collect addresses) so that the web3 project will be able to reward them. This would make rewarding loyal community members very easy.</p><ul><li><strong>Event Streaming App</strong></li></ul><p>Most big web3 events live stream on YouTube. What if there was a platform where web3 events are livestreamed? Users can go anonymous when they are watching the event.</p><ul><li><strong>A platform for Crypto Traders</strong></li></ul><p>There is a popular trend in trading where traders copy trading signals to make a profit together. Copy trading can be made easier when traders can hop on a call, share a signal and monitor trading together. Integrating trading platforms into Huddle01 technology makes building this possible.</p><h4>Conclusion</h4><p>In this article, I have introduced Huddle01 technology and its SDK. Apps that have been built with Huddle01 SDK and interesting ideas you can try out by leveraging Huddle01 have been discussed. You can start with one of the ideas I mentioned in this article.</p><p>Here are important links and resources that can help you while building your application:</p><ul><li><a href="https://huddle01.com/"><strong>Huddle01 website</strong></a></li><li><a href="https://docs.huddle01.com/docs"><strong>Documentation</strong></a></li><li><a href="https://docs.huddle01.com/docs/React/example#react-sample-app"><strong>Guides and sample apps</strong></a></li></ul><p>If you encounter a problem, Huddle01&#39;s community is always there to put you through. You can join:</p><ul><li><a href="https://discord.com/invite/huddle01"><strong>Discord</strong></a></li><li><a href="https://twitter.com/huddle01com"><strong>Twitter</strong></a></li><li><a href="https://github.com/Huddle01"><strong>Github</strong></a></li><li><a href="https://www.youtube.com/channel/UC7NPokItnEXtZ4UvqiHMKPQ"><strong>YouTube</strong></a></li></ul><p>Happy building!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=802bcf6c58d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Web Worker API In Your Reactjs Project To Enhance Performance]]></title>
            <link>https://medium.com/@andika.techwrite/using-web-worker-api-in-your-reactjs-project-to-enhance-performance-689b0404cb27?source=rss-2dec45978567------2</link>
            <guid isPermaLink="false">https://medium.com/p/689b0404cb27</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Andika Tech]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 12:42:05 GMT</pubDate>
            <atom:updated>2024-04-24T12:42:05.520Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Using Web Worker API In Your Reactjs Project To Enhance Performance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r-Vndlq_Y1rqeDlY" /><figcaption>Photo by <a href="https://unsplash.com/@clemhlrdt?utm_source=medium&amp;utm_medium=referral">Clément Hélardot</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What is a web worker?</p><p>This is a question beginners learning frontend often ask. Sometimes, they can&#39;t wrap their head around reasons for using the web worker API and when it should be used.</p><p>Web Workers in simple terms, are a means to run a set of instructions in the background. Why background? Javascript was created in 1995 to run small bits of tasks on the web browser. Javascript is designed to run non-concurrently (i.e. run one task at a time) on a single main thread. Web Worker makes it possible to create another thread called the worker thread to run tasks, without interfering with the user interface.</p><p>Developers use Web Worker API to ease the burden of tasks on the main thread. Running memory-intensive tasks like implementing autosave functionality (for writing web apps, e.g. Google Docs), can affect user interactions and cause lagging. Web worker makes it possible to assign those tasks to another thread.</p><figure><img alt="Diagram showing the flow of tasks on the browser with, and without web worker" src="https://cdn-images-1.medium.com/max/471/1*RsIWQrZv42tzEXEP-nPB5Q.png" /><figcaption>Left: Without web worker, Right: With web worker</figcaption></figure><p>Using web worker in cases like the one mentioned above helps to;</p><ul><li>improve the responsiveness and avoid freezing of the web app,</li><li>improve the overall performance of the web app, and</li><li>better make use of the CPU resources by utilizing multiple threads</li></ul><h4><strong>Real-World Use Cases of Web Workers</strong></h4><p>Web worker is used in web applications that have the following features:</p><ol><li><strong>Image processing</strong>: For web apps with features like image resizing, filtering, manipulation and facial recognition. Web workers can be used for complex canvas manipulations or image rendering in the background.</li><li><strong>Video encoding and decoding: </strong>Developers use web workers in streaming apps to process video files for playback or manipulation without freezing the user interface.</li><li><strong>Real-time applications:</strong> Real-time applications that use socket.io for fetching data. Web apps like messaging platforms, and crypto dashboard shows the latest price of cryptocurrencies in a chart.</li><li><strong>Background Tasks:</strong> Web workers can handle tasks that don’t require immediate visual updates on the page. Examples include syntax highlighting in online code editors. It is also used to fetch large amounts of backend API data.</li></ol><h4>Web Worker API</h4><p>There are two types of web workers:</p><p><strong>Shared Worker</strong></p><p>The shared worker is accessible to multiple pages and scripts. The shared worker is spawned by calling the SharedWorker() constructor.</p><pre>const worker = new SharedWorker(&#39;worker.js&#39;)</pre><p><strong>Dedicated Worker</strong></p><p>A dedicated worker is only accessible to the script that called it. This way, only the page that called it can communicate with it.</p><p>A dedicated worker is created by calling the Worker() constructor. The constructor takes the script&#39;s path to run in the worker thread as a parameter.</p><pre>const worker = new Worker(&#39;worker.js&#39;)</pre><h4>Communication with a dedicated worker</h4><p>To send a message to and from a dedicated worker, postMessage() is used. The onmessage method is for listening to messages.</p><p>The postMessage() takes in the data or message to be sent as a parameter. The data can be any javascript object, with exemptions like functions and DOM nodes. This is because data is copied between the main page and the worker, not shared. The page and worker do not share the same instance, i.e. duplicate result is created on each side.</p><h4>Terminating web worker</h4><p>To terminate a running web worker from the main thread, the terminate() method is used.</p><h4>Web Worker Limitations</h4><p>While web worker API is a powerful tool to improve performance, there are a few limitations to keep in mind when working with them.</p><ul><li>Web workers do not have access to all window objects, e.g. window.location</li><li>It can not directly manipulate the DOM. 🙅‍♂️ No document.addEventListener()</li></ul><p>Checkout list of functions and classes available to web workers: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers">https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers</a></p><h4>Implementing web worker in Reactjs applications</h4><p>To better understand the concept of how web workers work, let’s consider an example in a Reactjs app.</p><p>To imitate a memory-intensive task, we will create a function that returns the <a href="https://en.wikipedia.org/wiki/Factorial">factorial</a> of a random number from 0–100.</p><pre>//Memory-intensive calculation<br><br>export default function calcFactorial() {<br>const randomNum = Math.floor(Math.random() * 100);<br>let factorial = 1;<br>if (randomNum === 0) {<br>return 1;<br>}<br>for (let i = 1; i &lt;= randomNum; i++) {<br>factorial *= i;<br>}<br>return factorial;<br>}</pre><p>To create a web worker, we need a jsfile (e.g. worker.js). In this file, we listen to messages from app.js using the onmessage method. The message.data from the parameter is a boolean that determines if the calculation should start or stop. If message.data is true, we run calcFactorial() and send the returned value to app.js every 2 seconds.</p><pre>//worker.js<br><br>import calcFactorial from &quot;../utils/randomNum&quot;;<br>onmessage = function (message) {<br>const init = message.data;<br>if (init) {<br>setInterval(() =&gt; {<br>const randomFactorial = calcFactorial();<br>postMessage(randomFactorial);<br>}, 2000);<br>} else {<br>return;<br>}<br>};</pre><p>In app.js , we initialize a dedicated worker and communicate with the worker.js file using postMessage() and onmessage methods.</p><pre>import { useState, useEffect } from &quot;react&quot;;<br><br>function App() {<br><br>//initialize web worker<br>const worker = new Worker(new URL(&quot;./worker/worker.js&quot;, import.meta.url), {<br>type: &quot;module&quot;,<br>});<br><br>const [initWorker, setInitWorker] = useState(false);<br>const [randomFactorial, setRandomFactorial] = useState(0);<br><br>useEffect(() =&gt; {<br><br>//communicates with the worker file<br>if (initWorker) {<br>worker.postMessage(true);<br>}<br>worker.onmessage = function (e) {<br>setRandomFactorial(e.data);<br>};<br><br>return (()=&gt;{<br>worker.terminate()<br>})<br>}, [initWorker, randomFactorial]);<br><br>const handleClick = () =&gt; {<br>setInitWorker(!initWorker);<br>};<br><br>return (<br>&lt;div&gt;<br>&lt;h1&gt;Web worker example&lt;/h1&gt;<br>&lt;div className=&#39;randomNumBox&#39;&gt;<br>&lt;h2&gt;Random Factorial: {randomFactorial}&lt;/h2&gt;<br>&lt;button onClick={handleClick}&gt;{initWorker ? &quot;Stop&quot; : &quot;Start&quot;}&lt;/button&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>);<br>}<br>export default App;</pre><h4>Result</h4><figure><img alt="This is a video of the page we created" src="https://cdn-images-1.medium.com/max/600/1*h6bRLXiwVhvir2OajNNNrw.gif" /><figcaption>React app with web worker</figcaption></figure><p><a href="https://github.com/psalmuelle/andika-tutorial/tree/worker">https://github.com/psalmuelle/andika-tutorial/tree/worker</a></p><h4>Conclusion</h4><p>In this article, we explored the web worker API and how it is being used to improve web performance. Here are additional resources to know more about web worker API:</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API</a></li><li><a href="https://www.w3schools.com/html/html5_webworkers.asp">https://www.w3schools.com/html/html5_webworkers.asp</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=689b0404cb27" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>