sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
17.81k stars 1.78k forks source link

Enable adapter-static to connect with adapter-node backend by simply supplying URL #12125

Closed bluepuma77 closed 3 weeks ago

bluepuma77 commented 1 month ago

Describe the problem

I would like to create a mobile app from of my SvelteKit web application. CapacitorJS enables this, it can package a static SvelteKit app into a mobile application (Ionic CapacitorJS blog, svelte-capacitor-recipe, sveltekit-capacitor-starter, capkit), available on an App Store.

My current understanding is that an adapter-static build does not include the automatic fetch functionality that a regular adapter-node SvelteKit web app has included. So for every SvelteKit page I have to manually generate the fetch logic.

Describe the proposed solution

It would be great if adapter-static could be used to build a static SvelteKit web application, that can still connect to a regular SvelteKit (adapter-node) backend by simply supplying the backend URL during build or runtime.

Further enhancement would be to modify this fetch functionality centrally to supply a http header like access token.

Alternatives considered

Manually generate fetch logic for every page implemented.

Importance

would make my life easier

Additional Information

No response

bluepuma77 commented 3 weeks ago

@Rich-Harris, @benmccann, @dummdidumm, @Conduitry:
Sorry for mentioning, would love to get a quick comment if this is already possible, something desirable or out of scope.

Conduitry commented 3 weeks ago

Please don't ping maintainers.

I'm really not sure what this is asking for. +page.js and load do work in adapter-static apps. Have you tried it? If you want to prevent pages from getting rendered as HTML during build so that they'll instead get rendered by the browser at runtime, you can also do that.