Replies: 17 comments
-
I recently built a Capacitor app + PWA from the same code base, you can read a blog post about the architecture here. I did not use SSR because it was not necessary for my use case, but there is nothing to prevent you from that. There is already a switch, set:
...in your |
Beta Was this translation helpful? Give feedback.
-
@khromov thanks for the reply, I'm reading the blog. Yes indeed we have made cap svelte PWAs apps before. But we want SSR for web/performance/seo reasons while maintaining the same code-base for PWA, so the best of both worlds. The issue with the pre-script is, how do the +server scripts work? |
Beta Was this translation helpful? Give feedback.
-
@khromov I noticed you're not using platform native transitions, I tried to swipe back and couldn't in your app, you can do this easily in Capacitor, any reason why? |
Beta Was this translation helpful? Give feedback.
-
+server.ts files are stripped from the output if you compile with
I'm not familiar with this, is it a plugin or something in Capacitor core? You can send a link and I'll check it out. |
Beta Was this translation helpful? Give feedback.
-
@khromov capacitor includes native page transitions with a custom view controller: https://capacitorjs.com/docs/ios/viewcontroller. It doesn't work on simulator only real device. Yes I saw that in your post Is the code then exported an executed a layer above in static JS for example? |
Beta Was this translation helpful? Give feedback.
-
@khromov you can use this code to make it feel more 'native' ionic-team/capacitor#1097 (comment) |
Beta Was this translation helpful? Give feedback.
-
@ollyde If you set |
Beta Was this translation helpful? Give feedback.
-
@khromov yes but what do you mean by executed. Do you mean server.ts will be run on the client before the page is displayed allowing data to be passed to it? If that is the case how do we show loading indicators on the client then? |
Beta Was this translation helpful? Give feedback.
-
@ollyde Server endpoints are never executed on the client. In the context of For example if you had |
Beta Was this translation helpful? Give feedback.
-
@khromov oh that's a shame, hence why this ticket exists. Would be nice to have +server.ts converted to some client-side caller with loading indicator options. Of course not all +server files can do this, but My quest is to get SSR working on hosted platforms and PWA working for apps without any configuration :D |
Beta Was this translation helpful? Give feedback.
-
It would be helpful if you specified how you would imagine it to work, for example, what files would be created, how would the code look (provide a "pseudo-code" example), and what would the output be like + a pipeline of how the data flow. As for your last message, "client-side caller with loading indicator options" is exactly what a |
Beta Was this translation helpful? Give feedback.
-
@khromov the +page::load function only runs on the client to make requests no? Unless I missing something out here. |
Beta Was this translation helpful? Give feedback.
-
@ollyde +page load is called "universal" and also runs on the server, please see: |
Beta Was this translation helpful? Give feedback.
-
So the PWA can also use page load, but then how do indicators and the like work? For example if I use an infinite double way list? |
Beta Was this translation helpful? Give feedback.
-
You have to build your own loading indicator, you can do this for example using If you prefer to do the load state in your component, you can use streaming promises: All of this works with adapter-static. You might like the official Svelte Discord channel, it's better suited for open-ended discussion: |
Beta Was this translation helpful? Give feedback.
-
@khromov thanks for this info. Going to give this a try. |
Beta Was this translation helpful? Give feedback.
-
It seems like I am describing the same "Dynamic SSR/PWA" issue in #10332, but the discussion is much better. I also made a repo to reproduce the issue I'm having at https://github.com/NatoBoram/bug-report-sveltekit-ssr-csr |
Beta Was this translation helpful? Give feedback.
-
Describe the problem
I have a SvelteKit app, working great.
I want to be able to export the app to Capacitor, so need static assets and code.
Would be the most awesome kick-ass thing ever if I could have two build settings.
And would be super-mega-awesome if this could switch automatically and the code would magically work.
Describe the proposed solution
Enable a switch to allow SSR apps to create static assets for PWAs without changing code.
Alternatives considered
:*-(
Flutter..
Importance
would make my life easier
Additional Information
Making this feature work will bring us into a new dimension for development.
No response
Beta Was this translation helpful? Give feedback.
All reactions