Repository navigation
feat(sveltekit): support SvelteKit 3 and @prismicio/svelte v3 - #418
Merged
Merged
Conversation
…oject The CLI always installed the newest @prismicio/svelte. After v3 is published, that version does not support older Svelte and SvelteKit projects. The generated slice simulator page also used the slot syntax that v3 removes. The CLI now installs v3 when Svelte is 5.16 or later and SvelteKit is 2.27 or later. Otherwise, it installs v2. The slice simulator page uses the syntax of the installed major. Setup now stops with an error for Svelte 4. @prismicio/svelte v1 has no slice simulator, and the generated files need Svelte 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
4 tasks
Choosing a @prismicio/svelte major from the project's Svelte and SvelteKit versions added complexity for old projects. SvelteKit setup now supports only @prismicio/svelte v3. It installs the latest version and always generates Svelte 5 code. The package manager reports projects that are too old through the v3 peer dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The root layout head markup and the preview layout step each had one use left, so they are now inline. The tests no longer fake a Svelte version because the SvelteKit adapter does not read it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
angeloashmore
marked this pull request as ready for review
October 14, 2026 02:33
SvelteKit 3 removes the $lib alias. Projects that used the generated files failed to build with a module_removed_lib error. The generated files now import from #lib with a file extension, as SvelteKit 3 projects require. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e3cbe28. Configure here.
SvelteKit 3 deprecates $env/dynamic/public. The generated Prismic client used it, so it warned in development and failed type checks. The client now reads PUBLIC_PRISMIC_ENVIRONMENT from $app/env/public. Setup creates src/env.ts or src/env.js to declare the variable. If the project already has an env file without the variable, setup leaves the file as it is and tells the user which lines to add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
In SvelteKit 3, the website reads PUBLIC_PRISMIC_ENVIRONMENT only when src/env declares it. Without the declaration, prismic env set had no effect and gave no warning. prismic env set now prints the open setup steps, like prismic preview add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Two templates needed only the file extension, not the TypeScript flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The SvelteKit adapter now generates code for SvelteKit 3. SvelteKit 2 projects cannot use that code or @prismicio/svelte v3. A separate adapter now handles SvelteKit 2 projects. It installs @prismicio/svelte v2 and generates $lib and $env/dynamic/public code, as before. It extends the SvelteKit 3 adapter, so we can delete it when SvelteKit 2 support ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Most SvelteKit 2 templates differed from the SvelteKit 3 templates only in their $lib and $env imports. They now reuse the SvelteKit 3 output and change only those imports. The generated files are the same. The CLI now picks the SvelteKit 2 adapter from the @sveltejs/kit range in package.json. Before, a SvelteKit 2 project without node_modules got the SvelteKit 3 adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
getAdapter parsed the @sveltejs/kit range itself. getInstalledMajor now reads a simple range from package.json when the package is not installed, so getAdapter uses it directly. Other ranges, like "latest" or a Git URL, still mean the newest major. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The helper only reads package.json and installed packages, so it belongs with the other package.json helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The SvelteKit 2 adapter has its own copy of the setup and instruction logic. These tests make sure that the copy keeps the same behavior as the SvelteKit 3 adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Both tests set up the same server layout. One test now checks all of the results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
@prismicio/svelte v2 requires Svelte 5, so the Svelte 4 code that SvelteKit setup generated did not work. Setup, slice components, and setup instructions now always use Svelte 5 syntax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
getInstalledMajor assumed the newest major when a package was not in node_modules. It now reads a simple range like "^15.0.0" from package.json first. The helper moves to lib/packageJson, next to the other package.json helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
A new environment has no effect until the project setup is finished. prismic env set now prints the open setup steps, like prismic preview add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
This was referenced Oct 14, 2026
SvelteKit 3 removes $lib and deprecates $env/dynamic/public, so new SvelteKit projects failed to build after setup. @prismicio/svelte v3 supports only SvelteKit 3, and v2 supports only SvelteKit 2. SvelteKit 3 projects now get @prismicio/svelte v3 and code that builds on SvelteKit 3. Setup declares PUBLIC_PRISMIC_ENVIRONMENT in src/env. SvelteKit 2 projects use a separate adapter that keeps @prismicio/svelte v2 and the code they get today. We can delete that adapter when SvelteKit 2 support ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The branch now builds on the split-out PRs. This merge keeps the earlier commits so the branch can update without a force-push. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
angeloashmore
changed the base branch from
main
to
claude/env-set-setup-steps
October 14, 2026 19:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY # Conflicts: # test/env-set.test.ts
getAdapter detects frameworks from peer dependencies too, so getInstalledMajor now reads a peer range when the package is not a dependency or dev dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
The test for a project without node_modules now checks only that setup works. A separate test checks that setup uses the declared Next.js version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY # Conflicts: # test/gen-setup.test.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY # Conflicts: # test/env-set.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves:
Description
This PR adds support for SvelteKit 3. SvelteKit 3 projects get
@prismicio/sveltev3 and code that builds on SvelteKit 3.It keeps SvelteKit 2 projects working as before, with
@prismicio/sveltev2.Merge this PR only after
@prismicio/sveltev3 is on npm.Checklist
Preview
How to QA 1
After v3 is published, run
prismic initin a newsv createproject, then runnpm run build. Open the slice simulator in the Page Builder and make sure that it shows your slices. Then do the same in a SvelteKit 2 project and make sure that it installs@prismicio/sveltev2.🤖 Generated with Claude Code
https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY
Note
Medium Risk
Framework detection and generated project scaffolding changed across two SvelteKit majors; mistakes could break init/setup for new or legacy Kit projects until caught by e2e tests.
Overview
Adds SvelteKit 3–compatible codegen and keeps SvelteKit 2 on a separate adapter path so
prismic init/gen setupproduce projects that build under currentsv create.SvelteKit 3 (default adapter): Generated code switches to
#lib/...imports with file extensions, readsPUBLIC_PRISMIC_ENVIRONMENTfrom$app/env/public, and creates or documentssrc/envviadefineEnvVars. The slice simulator uses@prismicio/sveltev3’s snippet API instead oflet:slices. Setup instructions can include an env-var step when an existingsrc/envomitsPUBLIC_PRISMIC_ENVIRONMENT.SvelteKit 2:
getAdapter()picksSvelteKit2Adapterwhen installed@sveltejs/kitis major < 3. That adapter extends the main one but pins@prismicio/svelte^2 and reuses templates transformed for$lib,$env/dynamic/public, and slot-basedSliceSimulator.Shared helpers (
findSourceFile, exporteddeleteStarterHomePage) support both paths. Tests and preview evals cover SK2/SK3, env handling, and#libvs$libpage generation; AGENTS.md documents version-specific adapter files.Reviewed by Cursor Bugbot for commit 2a2cb8c. Bugbot is set up for automated code reviews on this repo. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩