lynx icon indicating copy to clipboard operation
lynx copied to clipboard

[Feature]: svelte guide

Open MentalGear opened this issue 11 months ago • 19 comments

What problem does this feature solve?

In the spirit of being framework-agnostic, please provide integration guides for other modern mainstream frameworks like Svelte(kit), instead of only React.

What does the proposed API of configuration look like?

Since Lynx is a framework-agnostic, here's hoping this would only require an entry in the docs.

MentalGear avatar Mar 06 '25 18:03 MentalGear

Someone's just seen the latest Fireship video LOL

matthewblott avatar Mar 06 '25 19:03 matthewblott

+1

cliffordkleinsr avatar Mar 06 '25 19:03 cliffordkleinsr

+1

Krulknul avatar Mar 06 '25 23:03 Krulknul

+1 Svelte fanboy here 🙋

enisbudancamanak avatar Mar 07 '25 02:03 enisbudancamanak

Hi folks, Thanks a lot for your question and we very welcome such contribution/community implementation. This is a very huge topic. I guess this can't be explained in this one simple comment.

I wish this simple comment would help you guys.

Step 0. make it work with rspeedy

https://github.com/lynx-family/lynx-stack/blob/main/packages/rspeedy/plugin-react/src/entry.ts

Here is the source code of Reactlynx plugin.

Note that the key point is u need to make the @lynx-js/template-webpack-plugin happy ;).

Step 1. rewrite DOM operation into Lynx's Element PAPI

https://lynxjs.org/api/engine/element-api/__CreateElement.html

The point is that we should replace document.createElement by __CreateElement

Step 2. Implement a compile-time tools to split code into two threads

Some APIs only exist in BTS, like NativeModules, lynx.fetch and etc. So this is essential to make your code work.

This could be very complicate.

PupilTong avatar Mar 07 '25 03:03 PupilTong

From what I understand, before Lynx can have a Svelte adapter, Svelte first needs to support custom renderers, i.e. be able to compile to a different set of instructions that Lynx can implement.

dummdidumm avatar Mar 07 '25 11:03 dummdidumm

Thanks for the awesome platform and making it framework agnostic!

Note that the key point is u need to make the @lynx-js/template-webpack-plugin happy ;)

I wonder if you might consider supporting Vite at some point. Svelte has better support for Vite than webpack and much more expertise for it in the community. It looks like Vite will overtake webpack in downloads sometime this year as it's a more popular solution for new projects

Some APIs only exist in BTS

What is BTS?

This could be very complicate.

What is involved in doing this?

A reactive framework based on template syntax will be released later this year.

What template syntax are you referring to? Will users use that template syntax or it's behind the scenes for users and the Svelte implementation uses it? How does Svelte's template syntax fit into the picture?

benmccann avatar Mar 07 '25 14:03 benmccann

Hi @benmccann , thanks for your questions.

I wonder if you might consider supporting Vite at some point. Svelte has better support for Vite than webpack and much more expertise for it in the community. It looks like Vite will overtake webpack in downloads sometime this year as it's a more popular solution for new projects

The key point is that Lynx is not running JS&CSS. The @lynx-js/template-webpack-plugin converts the JS/CSS code into a binary code which allows rendering engine to "recognize" it. Therefore the Vite is able to work if the @lynx-js/template-webpack-plugin is rewritten for Vite.

What is BTS?

https://lynxjs.org/blog/lynx-unlock-native-for-more.html

Lynx is designed for two-thread-model. Every Lynx page is running with two Javascript threads. Some APIs are only available in Main Thread, some of them are only available in the Background Thread.

Based on such assumption, the thread splitting could be essential if your framework doesn't require your developers to split the code manually.

PupilTong avatar Mar 07 '25 16:03 PupilTong

+1 🚀

gzimbron avatar Mar 07 '25 17:03 gzimbron

Thanks for the added details @PupilTong! It does sound like the main blocker is custom renderer support in Svelte, so I've opened an issue to track that: https://github.com/sveltejs/svelte/issues/15470

benmccann avatar Mar 08 '25 00:03 benmccann

+1

Gokuldev23 avatar Mar 10 '25 04:03 Gokuldev23

+1

jahir9991 avatar Mar 10 '25 18:03 jahir9991

Please do not post comments saying "+1" or otherwise expressing interest. It accomplishes nothing except for burying the useful technical information in this thread. You can put a thumbs up on the issue if you'd like to express interest

benmccann avatar Mar 10 '25 18:03 benmccann

+1

Skaenyde avatar Mar 13 '25 02:03 Skaenyde

A nice update to share - Mainmatter has offered to sponsor the development of a Svelte custom renderer API!

(please no need to reply to this message with expressions of excitement. let's keep this ticket focused on implementing the feature)

benmccann avatar Mar 13 '25 15:03 benmccann

For those still watching this thread, Mainmatter has released a proof of concept renderer for connecting Svelte and Lynx.
https://github.com/mainmatter/svelte-lynx-integration Blog post about it

marcojdelarosa avatar May 23 '25 21:05 marcojdelarosa

Is there any new update?

ansarizafar avatar Aug 25 '25 07:08 ansarizafar

I believe that Mainmatter is waiting for a customer to sponsor finishing the work on this. From the blog post:

as you can see, there's still a lot to do, and even more to make this production-ready. So if you or your company are interested in building truly native apps with Svelte and want to support us getting this ready to use, please reach out!

Some of the foundational work in Svelte was merged. However, the custom renderer API itself has not been merged. As mentioned in the blog post, some feedback was received from the Threlte team, so Paolo felt the API should be reworked a bit.

Lately, Paolo has been working on the Svelte MCP server instead. If you have an interest in using Svelte with Lynx, please reach out to Mainmatter about sponsoring Paolo to cleanup his branch for the custom renderer and get it merged to Svelte.

benmccann avatar Oct 04 '25 21:10 benmccann

+1

i18nsite avatar Dec 05 '25 11:12 i18nsite