SDK — React

React Component

The ImgNodus React component handles file selection, upload progress, and returns the optimized CDN URL — all in one component.

Installation

npm install @imgnodus/react

Basic Usage

import { ImgNodusUpload } from '@imgnodus/react';

export default function MyPage() {
  return (
    <ImgNodusUpload
      apiKey={process.env.NEXT_PUBLIC_IMGNODUS_KEY}
      folder="avatars"
      onSuccess={(url) => console.log('Uploaded:', url)}
      onError={(err) => console.error(err)}
    />
  );
}

Props

PropTypeDescription
apiKeystringYour ImgNodus API key.
folderstring(Optional) Target folder in your bucket.
onSuccessfunction(url)Callback with the CDN URL of the uploaded image.
onErrorfunction(error)Callback if upload fails.
acceptstringMIME type filter. Default: "image/*".
maxSizeMBnumberMax file size in MB. Default: 5.

With Next.js (App Router)

'use client';
import { ImgNodusUpload } from '@imgnodus/react';

export default function UploadPage() {
  return (
    <main>
      <h1>Upload Your Photo</h1>
      <ImgNodusUpload
        apiKey={process.env.NEXT_PUBLIC_IMGNODUS_KEY}
        onSuccess={(url) => {
          // Save URL to your database
          fetch('/api/save-image', { method: 'POST', body: JSON.stringify({ url }) });
        }}
      />
    </main>
  );
}