Skip to content

fix: use relative imports to NuxtHub templates#34

Merged
onmax merged 1 commit intomainfrom
fix/secondary-storage-hub-kv-import
Jan 3, 2026
Merged

fix: use relative imports to NuxtHub templates#34
onmax merged 1 commit intomainfrom
fix/secondary-storage-hub-kv-import

Conversation

@onmax
Copy link
Collaborator

@onmax onmax commented Jan 3, 2026

Fixes #33

Problem

ESM loader error when using secondaryStorage: true - virtual modules hub:kv and hub:db cannot be imported via resolved alias paths.

Solution

Use relative imports to NuxtHub's generated templates (../hub/kv.mjs, ../hub/db.mjs) instead of resolved alias paths.

Before: import { kv } from '${hubKVPath}' (fails with ESM loader)
After: import { kv } from '../hub/kv.mjs' (works)

Also restores validation that hub:kv and hub:db aliases exist before using them.

StackBlitz

Link Expected
Bug nuxt-better-auth-33 ❌ Build fails with ESM loader error
Fix nuxt-better-auth-33-fixed ✅ Build succeeds

@vercel
Copy link
Contributor

vercel bot commented Jan 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nuxt-better-auth-docs Ready Ready Preview, Comment Jan 3, 2026 6:21pm

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 3, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
nuxt-better-auth-demo d42fa95 Jan 03 2026, 06:33 PM

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/onmax/nuxt-better-auth/@onmax/nuxt-better-auth@34

commit: d42fa95

@onmax onmax changed the title fix: use NuxtHub auto-imports instead of top-level hub: imports fix: use relative imports to NuxtHub templates Jan 3, 2026
Use relative paths (../hub/kv.mjs, ../hub/db.mjs) instead of resolved
alias paths to avoid ESM loader issues with virtual modules.
@onmax onmax force-pushed the fix/secondary-storage-hub-kv-import branch from 71f69c2 to d42fa95 Compare January 3, 2026 18:19
@onmax onmax closed this Jan 3, 2026
@onmax onmax deleted the fix/secondary-storage-hub-kv-import branch January 3, 2026 18:32
@onmax onmax restored the fix/secondary-storage-hub-kv-import branch January 3, 2026 18:32
@onmax onmax reopened this Jan 3, 2026
@onmax onmax merged commit 23f073b into main Jan 3, 2026
8 checks passed
@onmax onmax deleted the fix/secondary-storage-hub-kv-import branch January 3, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Top-level hub:kv import in secondary-storage.mjs causes build error

1 participant