Share Dialog

A dialog that mints a shareable download or upload link with a chosen expiry — driven by useFiles.

Mints a shareable link for one key. Download links go through url() — a signed URL where the adapter supports it, a permanent public one where it doesn't — while upload links go through signedUploadUrl(). Pick an expiry (clamped to the adapter's cap), choose inline vs. attachment, then copy.

"use client";import { useFiles } from "files-sdk/react";import { ShareDialog } from "@/components/files-sdk/share-dialog";const Example = () => {  const files = useFiles({ endpoint: "/api/files" });  return <ShareDialog files={files} fileKey="photos/sunset.jpg" />;};export default Example;

Installation

npx shadcn@latest add https://files-sdk.dev/r/share-dialog.json
pnpm dlx shadcn@latest add https://files-sdk.dev/r/share-dialog.json
bunx --bun shadcn@latest add https://files-sdk.dev/r/share-dialog.json

Usage

import { useFiles } from "files-sdk/react";

import { ShareDialog } from "@/components/files-sdk/share-dialog";

export function Row({ fileKey }: { fileKey: string }) {
  const files = useFiles({ endpoint: "/api/files" });

  return <ShareDialog files={files} fileKey={fileKey} />;
}

The component reads capabilities() when it opens, so the expiry presets are clamped to the adapter's signedUrl.maxExpiresIn and it warns when the backend can only return a permanent public URL. Pass mode="upload" to hand out a presigned upload target instead, or a custom trigger via children.

Props

Prop

Type

On this page