Skip to content

feat(sveltekit): support SvelteKit 3 and @prismicio/svelte v3 - #418

Merged
angeloashmore merged 38 commits into
mainfrom
claude/confident-dijkstra-601fnl
Oct 15, 2026
Merged

angeloashmore merged 38 commits into
mainfrom
claude/confident-dijkstra-601fnl

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Resolves:

Description

This PR adds support for SvelteKit 3. SvelteKit 3 projects get @prismicio/svelte v3 and code that builds on SvelteKit 3.

It keeps SvelteKit 2 projects working as before, with @prismicio/svelte v2.

Merge this PR only after @prismicio/svelte v3 is on npm.

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

After v3 is published, run prismic init in a new sv create project, then run npm 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/svelte v2.

🤖 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 setup produce projects that build under current sv create.

SvelteKit 3 (default adapter): Generated code switches to #lib/... imports with file extensions, reads PUBLIC_PRISMIC_ENVIRONMENT from $app/env/public, and creates or documents src/env via defineEnvVars. The slice simulator uses @prismicio/svelte v3’s snippet API instead of let:slices. Setup instructions can include an env-var step when an existing src/env omits PUBLIC_PRISMIC_ENVIRONMENT.

SvelteKit 2: getAdapter() picks SvelteKit2Adapter when installed @sveltejs/kit is major < 3. That adapter extends the main one but pins @prismicio/svelte ^2 and reuses templates transformed for $lib, $env/dynamic/public, and slot-based SliceSimulator.

Shared helpers (findSourceFile, exported deleteStarterHomePage) support both paths. Tests and preview evals cover SK2/SK3, env handling, and #lib vs $lib page 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

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment. ↩

…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
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
@angeloashmore angeloashmore changed the title feat(sveltekit): install the @prismicio/svelte major that fits the project feat(sveltekit)!: support only @prismicio/svelte v3 Oct 14, 2026
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 angeloashmore changed the title feat(sveltekit)!: support only @prismicio/svelte v3 feat(sveltekit): support only @prismicio/svelte v3 Oct 14, 2026
@angeloashmore
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
@angeloashmore angeloashmore changed the title feat(sveltekit): support only @prismicio/svelte v3 feat(sveltekit): support SvelteKit 3 and @prismicio/svelte v3 Oct 14, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/adapters/sveltekit.templates.ts Outdated
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
claude added 10 commits October 14, 2026 17:43
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
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
angeloashmore changed the base branch from main to claude/env-set-setup-steps October 14, 2026 19:09
claude added 18 commits October 14, 2026 19:13
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
Base automatically changed from claude/env-set-setup-steps to main October 14, 2026 19:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L53y5wowGHwtT4aZJ3UsHY

# Conflicts:
#	test/env-set.test.ts
@angeloashmore
angeloashmore merged commit f0b89aa into main Oct 15, 2026
25 of 26 checks passed
@angeloashmore
angeloashmore deleted the claude/confident-dijkstra-601fnl branch October 15, 2026 22:48
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.

2 participants