Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sanity-plugin-asset-source-unsplash

sanity-io42.2kMIT4.0.1TypeScript support: included

Use images from Unsplash.com in your Sanity Studio

sanity, plugin, images, unsplash, assets, source

readme

Sanity Asset Source Plugin: Unsplash

For the v2 version, please refer to the v2-branch.

What is it?

Search for photos on Unsplash and add them to your project right inside Sanity Studio.

Unsplash image selector

Installation

npm install --save sanity-plugin-asset-source-unsplash

or

yarn add sanity-plugin-asset-source-unsplash

Usage

Add it as a plugin in sanity.config.ts (or .js):

import { unsplashImageAsset } from 'sanity-plugin-asset-source-unsplash'

export default defineConfig({
  // ...
  plugins: [unsplashImageAsset()],
})

This will add unsplashAssetSource to all image-fields in Sanity Studio

Manually configure asset sources

If you need to configure when Unsplash should be available as an asset source, filter it out as needed in form.image.assetSources:

import { unsplashImageAsset, unsplashAssetSource } from 'sanity-plugin-asset-source-unsplash'

export default defineConfig({
  // ...
  plugins: [unsplashImageAsset()],
  form: {
    image: {
      assetSources: (previousAssetSources, { schema }) => {
        if (schema.name === 'movie-image') {
          // remove unsplash from movie-image types
          return previousAssetSources.filter((assetSource) => assetSource !== unsplashAssetSource)
        }
        return previousAssetSources
      },
    },
  },
})

Example Unsplash API Photo result

{
  "id": "1_CMoFsPfso",
  "created_at": "2016-08-27T05:14:20-04:00",
  "updated_at": "2019-11-07T00:01:26-05:00",
  "promoted_at": "2016-08-27T05:14:20-04:00",
  "width": 6016,
  "height": 4016,
  "color": "#170801",
  "description": "Minimal pencils on yellow",
  "alt_description": "two gray pencils on yellow surface",
  "urls": {
    "raw": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "full": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "regular": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "small": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "thumb": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjEwMDg3MX0"
  },
  "links": {
    "self": "https://api.unsplash.com/photos/1_CMoFsPfso",
    "html": "https://unsplash.com/photos/1_CMoFsPfso",
    "download": "https://unsplash.com/photos/1_CMoFsPfso/download",
    "download_location": "https://api.unsplash.com/photos/1_CMoFsPfso/download"
  },
  "categories": [],
  "likes": 4450,
  "liked_by_user": false,
  "current_user_collections": [],
  "user": {
    "id": "kA9qRJtrtA4",
    "updated_at": "2019-11-12T05:10:00-05:00",
    "username": "joannakosinska",
    "name": "Joanna Kosinska",
    "first_name": "Joanna",
    "last_name": "Kosinska",
    "twitter_username": "joannak.co.uk",
    "portfolio_url": null,
    "bio": null,
    "location": "Leeds",
    "links": {
      "self": "https://api.unsplash.com/users/joannakosinska",
      "html": "https://unsplash.com/@joannakosinska",
      "photos": "https://api.unsplash.com/users/joannakosinska/photos",
      "likes": "https://api.unsplash.com/users/joannakosinska/likes",
      "portfolio": "https://api.unsplash.com/users/joannakosinska/portfolio",
      "following": "https://api.unsplash.com/users/joannakosinska/following",
      "followers": "https://api.unsplash.com/users/joannakosinska/followers"
    },
    "profile_image": {
      "small": "https://images.unsplash.com/profile-1477941848765-f577d5c83681?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=32&w=32",
      "medium": "https://images.unsplash.com/profile-1477941848765-f577d5c83681?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=64&w=64",
      "large": "https://images.unsplash.com/profile-1477941848765-f577d5c83681?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=128&w=128"
    },
    "instagram_username": "joannak.co.uk",
    "total_collections": 26,
    "total_likes": 534,
    "total_photos": 209,
    "accepted_tos": true
  }
}

Example resulting asset document

{
  "ms": 7,
  "query": "*[_type == \"sanity.imageAsset\" \u0026\u0026 _id == \"image-a6904e5887baafcf72f686cfa3e98399fd3ff74a-2600x1548-jpg\"]",
  "result": [
    {
      "_createdAt": "2019-11-14T09:01:47Z",
      "_id": "image-a6904e5887baafcf72f686cfa3e98399fd3ff74a-2600x1548-jpg",
      "_rev": "fDOLlTLScw9kMkHEI4HC9S",
      "_type": "sanity.imageAsset",
      "_updatedAt": "2019-11-14T09:01:47Z",
      "assetId": "a6904e5887baafcf72f686cfa3e98399fd3ff74a",
      "creditLine": "Qingbao Meng by Unsplash",
      "extension": "jpg",
      "metadata": {
        "_type": "sanity.imageMetadata",
        "dimensions": {
          "_type": "sanity.imageDimensions",
          "aspectRatio": 1.6795865633074936,
          "height": 1548,
          "width": 2600
        },
        "hasAlpha": false,
        "isOpaque": true,
        "lqip": "data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAMABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAUHBv/EACMQAAIBAgYCAwAAAAAAAAAAAAECAwAEBQYREiExFDJBUWH/xAAWAQEBAQAAAAAAAAAAAAAAAAACAwX/xAAcEQACAgIDAAAAAAAAAAAAAAAAAQIREiFBUaH/2gAMAwEAAhEDEQA/AMbh2arnaqvdggfR1ppc52eOMi3V5SOyTwKjOFsxLNvbj9pniU81t4whlcCT2GvdZ8080RUK5KHNm6F33SBlfTkCiptcXkwk03dD5op2uvRbP//Z",
        "palette": {
          "_type": "sanity.imagePalette",
          "darkMuted": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#435c39",
            "foreground": "#fff",
            "population": 6.83,
            "title": "#fff"
          },
          "darkVibrant": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#698710",
            "foreground": "#fff",
            "population": 2.51,
            "title": "#fff"
          },
          "dominant": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#728863",
            "foreground": "#fff",
            "population": 6.83,
            "title": "#fff"
          },
          "lightMuted": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#bec6a9",
            "foreground": "#000",
            "population": 0.51,
            "title": "#fff"
          },
          "lightVibrant": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#cad67e",
            "foreground": "#000",
            "population": 0.62,
            "title": "#000"
          },
          "muted": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#728863",
            "foreground": "#fff",
            "population": 6.83,
            "title": "#fff"
          },
          "vibrant": {
            "_type": "sanity.imagePaletteSwatch",
            "background": "#91b31a",
            "foreground": "#000",
            "population": 1.83,
            "title": "#fff"
          }
        }
      },
      "mimeType": "image/jpeg",
      "originalFilename": "2bb1b89b-726e-4d1c-a148-7936f57a432f.jpeg",
      "path": "images/q2r21cu7/example/a6904e5887baafcf72f686cfa3e98399fd3ff74a-2600x1548.jpg",
      "sha1hash": "a6904e5887baafcf72f686cfa3e98399fd3ff74a",
      "size": 1101084,
      "source": {
        "id": "01_igFr7hd4",
        "name": "unsplash",
        "url": "https://unsplash.com/photos/01_igFr7hd4"
      },
      "url": "https://cdn.sanity.io/images/q2r21cu7/example/a6904e5887baafcf72f686cfa3e98399fd3ff74a-2600x1548.jpg"
    }
  ]
}

Futher reading

License

MIT-licensed. See LICENSE.

Develop & test

This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.

See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

changelog

📓 Changelog

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.1 (2025-08-15)

Bug Fixes

4.0.0 (2025-08-15)

⚠ BREAKING CHANGES

  • require sanity v4

Features

3.1.0 (2025-07-29)

Features

  • deps: upgrade @sanity/ui to v3 (fbdd83c)

3.0.4 (2025-07-10)

Bug Fixes

  • deps: allow studio v4 peer dep ranges (f2ebd6a)

3.0.3 (2025-01-28)

Bug Fixes

  • improve react 19 typings (7b87db1)

3.0.2 (2024-12-18)

Bug Fixes

3.0.1 (2024-04-11)

Bug Fixes

3.0.0 (2024-04-08)

⚠ BREAKING CHANGES

  • require styled-components v6 (#138)

Bug Fixes

2.0.1 (2024-03-12)

Bug Fixes

  • improve UX of search input (5ac85fd)

2.0.0 (2024-03-12)

⚠ BREAKING CHANGES

  • update dependency @sanity/ui to v2 (#127)

Bug Fixes

1.1.2 (2023-10-23)

Bug Fixes

  • deps: update dependency styled-components to v6 (13266e2)

1.1.1 (2023-09-03)

Bug Fixes

1.1.0 (2023-05-23)

Features

1.0.7 (2023-05-23)

Bug Fixes

  • deps: update dependencies (non-major) (#83) (f0d8e9a)
  • don't steal focus from the search input (6810a7c)

1.0.6 (2023-01-12)

Bug Fixes

  • redraw unsplash logo to match the @sanity/icons grid (5997b28)

1.0.5 (2023-01-12)

Bug Fixes

  • deps: update dependency react-photo-album to v2 (#68) (4748ce0)

1.0.4 (2023-01-12)

Bug Fixes

  • adjust unsplash logo negative space with viewBox instead of CSS transform: scale (d10e532)
  • better deduping of shared dependencies (6b9eff7)
  • replace lodash/flatten with native Array.flat (90f8c07)

1.0.3 (2023-01-04)

Bug Fixes

  • deps: applied npx @sanity/plugin-kit inject (a2631da)

1.0.2 (2023-01-03)

Bug Fixes

  • docs: formBuilder.image.assetSource should be form.image.assetSource (36991e6)
  • vertically center unsplash logo (dfa2612)

1.0.1 (2022-11-25)

Bug Fixes

  • deps: sanity ^3.0.0 (works with rc.3) (2c4b6de)

1.0.0 (2022-11-17)

⚠ BREAKING CHANGES

  • this version does not work in Sanity Studio v2
  • No longer works in Studio V3

Features

  • initial Sanity Studio v3 release (299e0ff)
  • studio v3 version (b96bc92)

Bug Fixes

  • bump to dev-preview.22 (d891e62)
  • compiled for sanity 3.0.0-rc.0 (7d38147)
  • deps: dev-preview.21 (3d27d95)
  • deps: pin dependency @sanity/ui to 1.0.0-beta.32 (#59) (ce459ce)
  • deps: pkg-utils & @sanity/plugin-kit (09a49c0)
  • deps: sanity 3.0.0-dev-preview.17 (fd846ce)
  • deps: sanity/ui 0.38 (8da5b91)
  • deps: update dependency rxjs to ^6.6.7 (v3) (#21) (0d323ec)
  • deps: update sanity packages to v1 (v3) (major) (#20) (2b1efd2)
  • replace parcel with @sanity/pkg-utils (46988fd)
  • set apiVersion in useClient (260e875)
  • styled-components is a peer dep (d2051e2)
  • update docs (3776bbc)
  • use currentColor in Unsplash logo svg (0c0b241)
  • use exact @sanity/ui version (62a260c)
  • use the same @sanity/ui as dev-preview (156970d)

3.0.0-v3-studio.13 (2022-11-04)

Bug Fixes

  • deps: pkg-utils & @sanity/plugin-kit (09a49c0)

3.0.0-v3-studio.12 (2022-11-03)

Bug Fixes

  • deps: pin dependency @sanity/ui to 1.0.0-beta.32 (#59) (ce459ce)

3.0.0-v3-studio.11 (2022-11-02)

Bug Fixes

  • compiled for sanity 3.0.0-rc.0 (7d38147)

3.0.0-v3-studio.10 (2022-10-25)

Bug Fixes

  • use exact @sanity/ui version (62a260c)

3.0.0-v3-studio.9 (2022-10-25)

Bug Fixes

  • deps: update dependency rxjs to ^6.6.7 (v3) (#21) (0d323ec)
  • replace parcel with @sanity/pkg-utils (46988fd)

3.0.0-v3-studio.8 (2022-10-24)

Bug Fixes

3.0.0-v3-studio.7 (2022-10-11)

Bug Fixes

  • styled-components is a peer dep (d2051e2)
  • use the same @sanity/ui as dev-preview (156970d)

3.0.0-v3-studio.6 (2022-10-07)

Bug Fixes

3.0.0-v3-studio.5 (2022-09-15)

Bug Fixes

3.0.0-v3-studio.4 (2022-09-15)

Bug Fixes

  • deps: sanity 3.0.0-dev-preview.17 (fd846ce)
  • set apiVersion in useClient (260e875)

3.0.0-v3-studio.3 (2022-08-17)

Bug Fixes

3.0.0-v3-studio.2 (2022-08-17)

Bug Fixes

  • deps: update sanity packages to v1 (v3) (major) (#20) (2b1efd2)

3.0.0-v3-studio.1 (2022-08-17)

Bug Fixes

  • use currentColor in Unsplash logo svg (0c0b241)

1.0.0-v3-studio.1 (2022-08-17)

  • feat!: studio v3 version (b96bc92)

BREAKING CHANGES

  • No longer works in Studio V3

0.2.2 (2022-05-05)

Features