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

@api.video/react-upload-button

v0.0.2

Published

api.video React upload button

Downloads

97

Readme

badge   badge   badge

npm ts

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

Table of contents

Project description

Customizable React button to upload to your api.video account.

Getting started

Retrieve your upload token

You'll need an upload token to use this component and upload to api.video. To get yours, follow these steps:

  1. Log into your account or create one here.
  2. Copy your API key (sandbox or production if you are subscribed to one of our plan).
  3. Go to the official api.video documentation.
  4. Log into your account in the top right corner. If it's already done, be sure it's the account you want to use.
  5. Go to API reference -> Upload Tokens -> Generate an upload token
  6. On the right, be sure the "Authentication" section contains the API key you want to use.
  7. Generate your upload token by clicking the "Try It!" button in the right section
  8. Copy the "token" value from the response in the right section.

Installation

npm install @api.video/react-upload-button
# or
yarn add @api.video/react-upload-button

Basic usage

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return <UploadButton uploadToken="YOUR_UPLOAD_TOKEN">Click Me</UploadButton>
}

Documentation

Props

| Name | Type | Mandatory | Description | | ---------------- | --------------------------------------- | --------- | ---------------------------------------------------------------- | | children | React.ReactNode | Yes | The button's children | | uploadToken | string | Yes | Your upload token | | style | React.CSSProperties | No | An object of style | | onUploadProgress | (progress: UploadProgressEvent) => void | No | Callback called during the uploading process | | onUploadSuccess | (video: VideoUploadResponse) => void | No | Callback called after the upload process has been completed | | onUploadError | (errorMessage: string) => void | No | Callback called in case of an error during the uploading process |

children

A ReactNode children.

Example:

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return <UploadButton>Click Me</UploadButton>
}

uploadToken

Your upload token, mandatory to upload a video to your api.video account.

Example:

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return (
    <UploadButton 
      // ...
      uploadToken="YOUR_UPLOAD_TOKEN"
      // ...
    >
      Click Me
    </UploadButton>
  )
}

style

A React.CSSProperties object, used for component styling.

Example:

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return (
    <UploadButton 
      // ...
      style={{ color: 'blue', background: 'red', }}
      // ...
    >
      Click Me
    </UploadButton>
  )
}

onUploadProgress

Callback called during the uploading process. An UploadProgressEvent object is accessible from it:

  • uploadedBytes (number): total number of bytes uploaded for this upload
  • totalBytes (number): total size of the file
  • chunksCount (number): number of upload chunks
  • chunksBytes (number): size of a chunk
  • currentChunk (number): index of the chunk being uploaded
  • currentChunkUploadedBytes (number): number of bytes uploaded for the current chunk

Example:

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return (
    <UploadButton 
      // ...
      onUploadProgress={(progress) => console.log(progress.uploadedBytes)}
      // ...
    >
      Click Me
    </UploadButton>
  )
}

onUploadSuccess

Callback called after the upload process has been completed. A Video object is accessible from it. Check the official documentation.

Example:

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return (
    <UploadButton 
      // ...
      onUploadSuccess={(video) => console.log(video.videoId)}
      // ...
    >
      Click Me
    </UploadButton>
  )
}

onUploadError

Callback called in case of an error during the uploading process. A string error message is accessible from it.

Example:

import { UploadButton } from "@api.video/react-upload-button"

export default function MyComponent() {
  return (
    <UploadButton 
      // ...
      onUploadError={(errorMessage) => console.log(errorMessage)}
      // ...
    >
      Click Me
    </UploadButton>
  )
}