Title: Dev: `better-auth/client/plugins` fails to resolve when auth is enabled (the `better-auth/client` alias matches it as a prefix) · Issue #565 · voidzero-dev/void · GitHub
Open Graph Title: Dev: `better-auth/client/plugins` fails to resolve when auth is enabled (the `better-auth/client` alias matches it as a prefix) · Issue #565 · voidzero-dev/void
X Title: Dev: `better-auth/client/plugins` fails to resolve when auth is enabled (the `better-auth/client` alias matches it as a prefix) · Issue #565 · voidzero-dev/void
Description: Description With auth enabled, void dev aliases better-auth/client (and /react, /vue, /svelte, /solid) to absolute file paths. A string alias in Vite also matches subpaths, so better-auth/client/plugins, where Better Auth's client plugin...
Open Graph Description: Description With auth enabled, void dev aliases better-auth/client (and /react, /vue, /svelte, /solid) to absolute file paths. A string alias in Vite also matches subpaths, so better-auth/client/pl...
X Description: Description With auth enabled, void dev aliases better-auth/client (and /react, /vue, /svelte, /solid) to absolute file paths. A string alias in Vite also matches subpaths, so better-auth/client/pl...
Opengraph URL: https://github.com/voidzero-dev/void/issues/565
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Dev: `better-auth/client/plugins` fails to resolve when auth is enabled (the `better-auth/client` alias matches it as a prefix)","articleBody":"## Description\n\nWith auth enabled, `void dev` aliases `better-auth/client` (and `/react`, `/vue`, `/svelte`, `/solid`) to absolute file paths. A string alias in Vite also matches subpaths, so `better-auth/client/plugins`, where Better Auth's client plugins such as `adminClient()` live, is rewritten to `…/better-auth/dist/client/index.mjs/plugins`, which doesn't exist. Any app that passes a Better Auth client plugin to `createAuthClient` breaks in dev. `void build` is not affected, because the alias is only added for `serve`.\n\n## Steps to reproduce\n\n1. Enable auth in `void.config.ts`: `auth: { providers: ['email'] }`.\n2. Add `better-auth` as a dependency (the same version Void uses).\n3. Create a client with a plugin and import it from a page:\n\n ```ts\n // src/lib/auth-client.ts\n import { adminClient } from 'better-auth/client/plugins';\n import { createAuthClient } from 'void/client';\n\n export const authClient = createAuthClient({\n basePath: '/api/auth',\n plugins: [adminClient()],\n });\n ```\n\n4. Run `void dev` and open that page.\n\n## Actual behavior\n\n- Client: `Pre-transform error: Failed to resolve import \"better-auth/client/plugins\" from \"src/lib/auth-client.ts\". Does the file exist?`\n- SSR: the page returns 500 with `Error: No such module \"workers/runner-worker/file:/…/better-auth/dist/client/plugins/index.mjs\"`.\n\n## Expected behavior\n\n`better-auth/client/plugins` resolves to `better-auth/dist/client/plugins/index.mjs`, as it does in `void build` and in Node.\n\n## Cause\n\n`packages/void/src/plugin-routing.ts` (main @ `6ba3dbcc3a`, lines 616–622):\n\n```ts\nconst betterAuthSubpaths = ['client', 'react', 'vue', 'svelte', 'solid'];\nconst resolvedAliases = betterAuthSubpaths.flatMap((sub) => {\n try {\n return [{ find: `better-auth/${sub}`, replacement: resolveFile(`better-auth/${sub}`) }];\n } catch {\n return [];\n }\n});\n```\n\nA string `find` matches the exact id and any id that starts with `find + '/'`, replacing the prefix. `resolveFile('better-auth/client')` is `…/dist/client/index.mjs`, so `better-auth/client/plugins` becomes `…/dist/client/index.mjs/plugins`.\n\n## Possible fix\n\nAnchor the patterns so they only match the exact specifier, and pre-resolve `client/plugins` too if it should avoid the lazy-discovery reload the comment mentions:\n\n```ts\nconst betterAuthSubpaths = ['client', 'client/plugins', 'react', 'vue', 'svelte', 'solid'];\n// …\nreturn [{ find: new RegExp(`^better-auth/${sub}$`), replacement: resolveFile(`better-auth/${sub}`) }];\n```\n\n## Workaround\n\nA plugin listed after `voidPlugin()` adds an exact-match alias. Aliases from a later plugin's `config` hook are tried first, so this one wins:\n\n```ts\n// vite.config.ts\nimport { createRequire } from 'node:module';\nimport type { Plugin } from 'vite-plus';\n\nconst require = createRequire(import.meta.url);\n\nfunction betterAuthClientPlugins(): Plugin {\n return {\n name: 'better-auth-client-plugins',\n config: () => ({\n resolve: {\n alias: [\n {\n find: /^better-auth\\/client\\/plugins$/,\n replacement: require.resolve('better-auth/client/plugins'),\n },\n ],\n },\n }),\n };\n}\n\n// plugins: [voidPlugin(), voidReact(), betterAuthClientPlugins()]\n```\n\n## Related\n\n#554 edits the same block (adds `authConfigEnvironmentConfig` to the returned config) but keeps the prefix aliases.\n\n## Environment\n\n- void 1.2.1 (also on 1.1.12), better-auth 1.7.11\n- vite-plus 1.3.0, Node 22.23.3, macOS 26.6\n","author":{"url":"https://github.com/karthickeyan-dev","@type":"Person","name":"karthickeyan-dev"},"datePublished":"2026-10-23T08:51:00Z","url":"https://github.com/voidzero-dev/void/issues/565"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ee572a9b-4857-ffc6-9933-154decf86611 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9D4:1F41:9F24F4:D19DDD:6AFBA693 |
| html-safe-nonce | a1bcb9ee9071728f69ebf20a15e2c699c29dcf11bb5c54449e29ee1ef803af34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUQ0OjFGNDE6OUYyNEY0OkQxOURERDo2QUZCQTY5MyIsInZpc2l0b3JfaWQiOiI4OTQ3MjY1MzMyOTcyMzMyNjkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | efc7378fc7eb58a1bec5cb7fe364e24585635910511bf10c9c11ddddd7108228 |
| hovercard-subject-tag | issue:5994820068 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/565/issue_layout |
| twitter:image | https://opengraph.githubassets.com/21230f3c5dcae9cf89994ecb1839cfd05cb1ee50268b96c0ec0de5a7fdde3ccf/voidzero-dev/void/issues/565 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/21230f3c5dcae9cf89994ecb1839cfd05cb1ee50268b96c0ec0de5a7fdde3ccf/voidzero-dev/void/issues/565 |
| og:image:alt | Description With auth enabled, void dev aliases better-auth/client (and /react, /vue, /svelte, /solid) to absolute file paths. A string alias in Vite also matches subpaths, so better-auth/client/pl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | karthickeyan-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 03e5090f0cea887cafa036e3af34d7c668d83b5e9e9e03df72a90efb49b69cdf |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 41f00295b9a35dca977890ab83b22788ab211dc8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width