SDK Configuration
Configure the SDK with custom options.
PinnerConfig Interface
interface PinnerConfig {
/** API authentication token. Required for all API operations. */
jwt: string;
/** API endpoint URL. Defaults to "https://ipfs.pinner.xyz" */
endpoint?: string;
/** IPFS gateway URL for content retrieval. Defaults to "https://dweb.link" */
gateway?: string;
/** Allowed MIME types for upload. If undefined, all types allowed. */
allowedFileTypes?: string[];
/** Custom fetch implementation. */
fetch?: typeof fetch;
/** Custom datastore instance for Helia. Highest priority - takes precedence over storage and datastoreName. */
datastore?: Datastore;
/** Custom storage instance for both Helia blockstore and datastore. Used when datastore is not provided. */
storage?: Storage;
/** Custom base name for Helia storage. Passed as the `base` option to both blockstore and datastore. Only used when neither datastore nor storage are provided. Defaults to "pinner-helia-data". */
datastoreName?: string;
}Endpoint Configuration
import { Pinner } from "@lumeweb/pinner";
// Default endpoint (https://ipfs.pinner.xyz)
const pinner = new Pinner({ jwt: "YOUR_API_TOKEN" });
// Custom endpoint
const pinner = new Pinner({
jwt: "YOUR_API_TOKEN",
endpoint: "https://staging.ipfs.pinner.xyz"
});Custom Gateway
import { Pinner } from "@lumeweb/pinner";
const pinner = new Pinner({
jwt: "YOUR_API_TOKEN",
gateway: "https://ipfs.io"
});Custom Fetch
import { Pinner } from "@lumeweb/pinner";
const pinner = new Pinner({
jwt: "YOUR_API_TOKEN",
fetch: window.fetch
});Storage Configuration
The SDK uses Helia for IPFS operations and provides three levels of storage configuration:
import { Pinner } from "@lumeweb/pinner";
// Level 1: Default storage (IndexedDB with base name "pinner-helia-data")
const pinner = new Pinner({ jwt: "YOUR_API_TOKEN" });
// Level 2: Custom base name
const pinner = new Pinner({
jwt: "YOUR_API_TOKEN",
datastoreName: "my-custom-storage"
});
// Level 3: Custom storage instance
import { createStorage } from "unstorage";
import indexeddbDriver from "unstorage/drivers/indexedb";
const storage = createStorage({
driver: indexedbDriver({ base: "my-app" })
});
const pinner = new Pinner({
jwt: "YOUR_API_TOKEN",
storage
});
// Level 4: Custom datastore instance (highest priority)
import { MemoryDatastore } from "interface-datastore";
const datastore = new MemoryDatastore();
const pinner = new Pinner({
jwt: "YOUR_API_TOKEN",
datastore
});Storage Priority
- datastore (highest) - Custom datastore instance used directly
- storage - Custom unstorage instance for both blockstore and datastore
- datastoreName - Custom base name for default storage
- default - Uses "pinner-helia-data" as base name
Environment-Specific Setup
export const config = {
jwt: process.env.DEV_PINNER_API_KEY,
endpoint: "https://staging.ipfs.pinner.xyz"
};