Search code examples
typescriptnext.jssanity

TypeError: (0 , next_sanity__WEBPACK_IMPORTED_MODULE_0__.createImageUrlBuilder) is not a function


I am trying to make nextjs typescript project using sanity.io but im not able to solve this problem. itis showing that createImageUrlBuilder is not a function.

enter image description here

here is my sanity module


Solution

  • createImageUrlBuilder is no longer wrapped by next-sanity and you'll need to install the dependency yourself (https://github.com/sanity-io/next-sanity#createimageurlbuilder-is-removed)

    $ npm install @sanity/image-url
    // or
    $ yarn add @sanity/image-url
    

    Notice also that createImageUrlBuilder is now a default import.

    -import { createImageUrlBuilder } from 'next-sanity'
    +import createImageUrlBuilder from '@sanity/image-url'