Better AuthBA
Better Auth10mo ago
5 replies
Logan

Vite cannot find "react" import in the npm package

I'm implementing the svelte demo in my sveltekit app as a test, and when running vite server, this error occurs:
✘ [ERROR] Could not resolve "react"

    node_modules/better-auth/dist/client/react/index.mjs:3:58:
      3 │ import { useRef, useCallback, useSyncExternalStore } from 'react';
        ╵                                                           ~~~~~~~


Running Node v23
Solution
Solved: The initial import of the library in the client was using "better-auth/react", needed to change it to "better-auth/svelte" to import the correct framework library.
Was this page helpful?