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

Option to disable client-side routing #570

Closed
wants to merge 4 commits into from

Conversation

benmccann
Copy link
Member

@ConProgramming wrote to support JungleJS as a SvelteKit adapter

Related: #231

Copy link
Member Author

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

I'm not that familiar with the new testing code, but if there's a way to write a simple test for this that'd probably be nice

Also, this should probably go in the docs at least in https://github.com/sveltejs/kit/blob/master/documentation/docs/13-configuration.md

@@ -5,6 +5,8 @@ module.exports = {
// specifying a different adapter
adapter: '@sveltejs/adapter-node',

clientSideRouting: false,
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if it might be better to make this routing: { client: false } or something in case we want to add other routing options. I'm curious what other folks think about names

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought about that maybe there should be an enum for routing, but Rich's original issue had it as clientSideRouting so I decided it'd be simpler to leave it as that

Copy link
Member

Choose a reason for hiding this comment

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

Aside from the flexibility of adding more routing options, for intellisense purposes it might also be better to provide a routing object because then 'client?', 'server?', etc. options would all show up localized in the object.

image

packages/kit/src/runtime/client/router.js Show resolved Hide resolved
@Rich-Harris
Copy link
Member

I can envisage cases where you might want to disable hydration on specific pages that you know to be purely static. Are there cases where you might want to disable client-side routing on specific pages as well? i.e. does this make sense?

<script context="module">
  export const prerender = true;
  export const hydrate = false;
  export const routing = false;
</script>

The answer to that presumably influences whatever API we settle on.

Separately, a Svelte-ish thing to do here would be to treeshake the router away if routing is disabled for a given app (or indeed page).

@ConProgramming
Copy link
Contributor

Being able to disable hydration on purely static pages would be nice - having the whole "0kb js" on static pages like elderjs can do.

My first thought is client side routing is all-or-nothing, but I guess someone could want authenticated pages with routing yet also static prerendered pages without it...

I thought about wanting to tree-shake away the router, but then I'd assume we'd want a simple reimplementation of "goto" to still work, just without csr?

@benmccann
Copy link
Member Author

Closing in favor of #713

@benmccann benmccann closed this Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants