SDK
Add Raster to a web app or plugin. Sign users in, browse, search, upload, and pick assets, or drop in the React picker.
The Raster SDK connects your app to a user's Raster libraries. It comes as two MIT-licensed npm packages:
@raster-app/react: the drop-inRasterPicker, plus React bindings. It includes everything in the core.@raster-app/sdk: the framework-free core, with the client, sign-in, image URL helpers, and formatters.
Install
For a React app (React 18 or 19):
npm install @raster-app/reactFor any other app:
npm install @raster-app/sdkBoth packages are ESM-only and run in the browser or Node.js 22.12+.
Quick start
RasterPicker is a complete asset picker. Render it inside a RasterProvider
and import its stylesheet:
import {
RasterPicker,
RasterProvider,
getFullSizeUrl,
localStorageCredentialStore,
} from '@raster-app/react'
import '@raster-app/react/styles.css'
export function Picker({ onImage }: { onImage: (url: string) => void }) {
return (
<RasterProvider
config={{
host: { name: 'My App', openExternal: (url) => window.open(url, '_blank') },
credentials: localStorageCredentialStore(),
}}
>
<RasterPicker onPick={(asset) => onImage(getFullSizeUrl(asset) ?? '')} />
</RasterProvider>
)
}host.nameis the app name Raster shows on its sign-in page.host.openExternalopens that page (see The host).localStorageCredentialStore()keeps the user signed in across reloads (see Where the credential is stored).
The picker fills its container, so give the container a height. With React
Server Components, render it from a Client Component ('use client').
In the picker, the user can:
- Sign in with a code they approve in Raster, or connect an organization API
key when
organizationIdis unset. - Choose an organization and library, or search the whole organization.
- Open an asset to see it large with its variants, open it in Raster, or pick
it when you pass
onPick. - Upload files to libraries they can write to, upload variants, and set a variant as the default.
onPick receives the Asset and its organization's id.
getFullSizeUrl(asset) returns its full-size URL.
Props
| Prop | Type | Description |
|---|---|---|
onPick | (asset: Asset, organizationId: string) => void | Called with the picked asset. Without it, the picker only browses and has no Pick asset button. |
organizationId | string | Limits sign-in to this organization. Granting another fails with ORGANIZATION_MISMATCH. See Sign in to one organization. |
scope | 'user' or 'org' | The access sign-in asks for. Defaults to 'org' with organizationId, 'user' without. |
onError | (error: RasterApiError) => void | Called for each error the picker shows. See Errors. |
theme | 'light' or 'dark' | Color scheme. Follows the system setting when unset. |
Next steps
- Authentication: device sign-in, API keys, and credential storage.
- React:
RasterPicker,RasterProvider, and hooks for your own UI. - Client:
createRasterClient, its methods, and helpers. - Errors:
RasterApiErrorand its codes.