Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace router/hydrate options with csr #6446

Merged
merged 4 commits into from
Aug 30, 2022
Merged

replace router/hydrate options with csr #6446

merged 4 commits into from
Aug 30, 2022

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Aug 30, 2022

Migration

export const router and export const hydrate where merged into export const csr. These two options really belong together, setting one to true and the other to false resulted in unexpected/buggy behavior. To migrate, remove the old options and replace them with the new option.

// +layout.js
- export const router = false;
- export const hydrate = false;
+ export const csr = false;

The following permutations are possible:

  • old: router = true / hydrate = true -> new: csr = true (this is the default, so you probably don't need to set this)
  • old: router = false / hydrate = false -> new: csr = false (no JS is loaded on the client)
  • old: router = false / hydrate = true -> new: csr = true + set data-sveltekit-reload if you want native navigations
  • old: router = true / hydrate = false -> new: csr = true (this was a buggy setting)

PR description

closes #6436

TODO:

  • update create-svelte templates
  • docs
  • noisy error if a page has hydrate or router exports

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2022

🦋 Changeset detected

Latest commit: 977ad1e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@MaximeMenotti
Copy link

Hi @Rich-Harris !
I use sveltekit in a micro-frontend like usage, injecting html and js generated by svelte-kit in another website.
I used router=false option to avoid sveltekit to interfere with the site but keep hydration to activate some js interaction.

I read in this PR that I should use this to keep same usage:

old: router = false / hydrate = true -> new: csr = true + set data-sveltekit-reload if you want native navigations

Unfortunately links like <a href="/" data-sveltekit-reload>Homepage</a> are still catch by sveltekit router.
Is there any other way or is it planned to allow to disable only the router for all links as it was the case before?
It was a very convenient feature for me, I hope I can find a solution.
Thanks and sorry to reopen this topic.

@lukaszpolowczyk
Copy link
Contributor

@MaximeMenotti To me, this is simply a bug that needs to be reported separately.

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.

Replace hydrate and router options with csr
4 participants