#7213 svelte c3 quickstart with lucia fails
Fundamental incompatibility: @node-rs/argon2 (used by lucia addon) has native bindings incompatible with Cloudflare runtime. C3 needs warning or docs for incompatible Svelte CLI addons.
Add warning about Cloudflare-incompatible Svelte addons or document workarounds
Analysis Report
Issue Review: cloudflare/workers-sdk#7213
Summary
SvelteKit projects created via C3 with the "lucia" auth addon fail to build for Cloudflare due to incompatible @node-rs/argon2 native/WASM dependencies.
Findings
- Created: 2024-11-10
- Updated: 2025-10-30
- Version: create-cloudflare 2.32.0 → 2.62.3 (current)
- Component: C3 (create-cloudflare) / SvelteKit integration
- Labels: bug
- Comments: 0
Key Evidence
Root cause identified: The Svelte CLI (
sv) lucia addon installs@node-rs/argon2which uses native Node.js bindings (.nodefiles) and WASM modules that are incompatible with Cloudflare Workers/Pages runtime.Related issues confirm this is a known limitation:
- SvelteKit #13061 (closed) - Same error, comments through Aug 2025 show ongoing issues
- Lucia #1567 (closed) - Maintainer confirmed: "@node-rs/argon2 doesn't work in CF"
- workers-sdk #6231 (closed) - Feature request for esbuild external support for same error
SvelteKit adapter fix (PR #13132, Dec 2024): Removed esbuild bundling step, but this doesn't solve the fundamental incompatibility - the runtime still cannot execute native bindings.
Lucia v3 deprecated (June 2025): The library this bug relates to has been deprecated, though the underlying issue with
@node-rs/argon2+ Cloudflare remains.No C3-specific fix exists: C3 delegates to
sv(Svelte CLI) which offers lucia addon without Cloudflare compatibility warnings.
Recommendation
Status: KEEP OPEN
Reasoning: This is a legitimate documentation/UX issue. While the root cause is an upstream incompatibility (@node-rs/argon2 cannot run on Cloudflare), C3 should either:
- Warn users when selecting lucia addon that it's incompatible with Cloudflare
- Document the workaround (use alternative hashing libraries like
bcryptjsor@oslojs/crypto) - Consider excluding incompatible addons from the sv CLI flow for Cloudflare projects
Action: Add documentation or warning about Cloudflare-incompatible Svelte CLI addons, particularly lucia.
Root Cause Analysis
The issue occurs in this flow:
- User runs
npx create-cloudflare --framework=svelte - C3 delegates to
sv(Svelte CLI) viapackages/create-cloudflare/src/frameworks/index.ts - User selects "lucia" addon in sv's interactive prompts
- sv installs
@node-rs/argon2as a dependency (lucia requires it for password hashing) - Build fails because
@node-rs/argon2uses:- Native Node.js bindings (
.nodefiles) - WASM modules (
@node-rs/argon2-wasm32-wasi) - Neither can be bundled/executed in Cloudflare's workerd runtime
- Native Node.js bindings (
Code path: packages/create-cloudflare/src/frameworks/index.ts:runFrameworkGenerator() - This function runs the framework CLI (sv) without any filtering of Cloudflare-incompatible options.
Proposed Solution
Option A (Minimal - Documentation):
Add a note to C3 docs and/or post-creation output warning about Cloudflare-incompatible Svelte addons.
Option B (Better - Runtime Warning):
After sv CLI completes, scan package.json for known incompatible packages and warn users:
// In packages/create-cloudflare/src/frameworks/svelte.ts or similar
const CLOUDFLARE_INCOMPATIBLE_PACKAGES = [
'@node-rs/argon2',
'@node-rs/bcrypt',
// other known incompatible packages
];
async function checkIncompatibleDependencies(projectPath: string) {
const pkgJson = JSON.parse(await readFile(join(projectPath, 'package.json'), 'utf-8'));
const allDeps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
const incompatible = CLOUDFLARE_INCOMPATIBLE_PACKAGES.filter(pkg => pkg in allDeps);
if (incompatible.length > 0) {
warn(`The following packages are incompatible with Cloudflare Workers/Pages:`);
incompatible.forEach(pkg => warn(` - ${pkg}`));
warn(`Consider using Cloudflare-compatible alternatives like bcryptjs or @oslojs/crypto`);
}
}
Option C (Best - Upstream coordination):
Work with SvelteKit team to add Cloudflare-specific addon filtering when sv detects it's being run in a Cloudflare context.
Implementation Difficulty
Medium
Justification:
- Option A (docs) is trivial
- Option B requires adding post-scaffold validation logic, understanding the package.json structure after sv runs, and maintaining a list of incompatible packages
- Option C requires cross-project coordination
Files to Modify
packages/create-cloudflare/src/frameworks/index.ts- Add post-scaffold compatibility checkpackages/create-cloudflare/src/frameworks/package.json- Potentially add new dependencies for scanning- Documentation files (if taking docs-only approach)
Testing Recommendations
- Manual testing: Run
npx create-cloudflare --framework=svelte, select lucia addon, verify warning appears - Unit tests: Add tests for incompatible package detection logic
- E2E tests: Verify the warning appears in the C3 output when incompatible packages are detected
Workarounds for Users
Users encountering this issue can:
- Don't select "lucia" addon during sv setup when targeting Cloudflare
- Use
bcryptjsor@oslojs/cryptoinstead of@node-rs/argon2 - Use the
argoniapackage (WASM-based argon2 for Workers, though has some limitations) - Implement custom hashing using Web Crypto API (scrypt)
Suggested Comment
This issue is caused by the
@node-rs/argon2package (installed by the lucia addon) using native Node.js bindings that are incompatible with Cloudflare Workers/Pages runtime.Workaround: When using C3 with SvelteKit for Cloudflare deployment, avoid selecting the "lucia" addon. Instead, use Cloudflare-compatible alternatives for password hashing:
bcryptjs(pure JS)@oslojs/crypto(pure JS)argonia(WASM-based, works on Workers but has some Pages limitations)We're keeping this open to track adding a warning or documentation about Cloudflare-incompatible Svelte CLI addons.
Notes & Feedback (0)
No notes yet.