Skip to content

Custom renderers support #15470

Open

Description

@benmccann

Describe the problem

Svelte 4 had foreign namespace to support Svelte Native. This was removed in Svelte 5 as the approach was not compatible with the new compiler implementation: #12709

Describe the proposed solution

Add a custom renderer API to support things like:

Importance

nice to have

Activity

  1. Ocean-OS commented on Mar 7, 2025

    @Ocean-OS
    Member

    I'm not too knowledgeable in this topic, but perhaps there could be a map of method names and/or a map of handlers for different features? Example:

    export const custom_renderer = {
        replacements: {
            state: 'ref' //$.state -> $.ref
        },
        handlers: {
            bind(prop, node, binding) {
                return x`$.bind(${node}, '${prop}', ${binding})`; //for bindings
            } 
        } 
    } 

    This could also include things like the boilerplate for each component.

  2. paoloricciuti commented on Mar 7, 2025

    @paoloricciuti
    Member

    I'm not too knowledgeable in this topic, but perhaps there could be a map of method names and/or a map of handlers for different features? Example:

    export const custom_renderer = {
    replacements: {
    state: 'ref' //$.state -> $.ref
    },
    handlers: {
    bind(prop, node, binding) {
    return x$.bind(${node}, '${prop}', ${binding}); //for bindings
    }
    }
    }
    This could also include things like the boilerplate for each component.

    I think rather than a replacement for state (I think the reactivity should still be handled by svelte otherwise it's just a matter of syntax) we should have replacements for dom operations. That said we should probably also have a more general hook to transform the compiled code because there might be the need to setup stuff before the component code for example.

  3. Pronian commented on Mar 7, 2025

    @Pronian

    Here is the Vue custom renderer API: https://vuejs.org/api/custom-renderer.html
    And the SolidJS one: https://github.com/solidjs/solid/tree/main/packages/solid/universal

    They are pretty similar. Do you think it would be good to make the Svelte API resemble something like that? (Would make porting existing solutions to Svelte easier)

  4. caracal7 commented on Mar 13, 2025

    @caracal7
  5. ethanannane commented on Mar 20, 2025

    @ethanannane

    +1 to this, I would love to see this work with Lynx!

  6. RoxDevvv commented on Apr 1, 2025

    @RoxDevvv

    +1

  7. joshua1 commented on Apr 9, 2025

    @joshua1

    +1 for this . any update please . This would be helpful for nativescript and lynx (potentially)

  8. paoloricciuti commented on Apr 9, 2025

    @paoloricciuti
    Member

    +1 for this . any update please . This would be helpful for nativescript and lynx (potentially)

    I'm actively working on this (well technically not now since I'm on vacation but you get the gist) since mainmatter (the company I work for) is sponsoring my work full time on this.

    There's already a PR open #15538 to have a new templating mode that doesn't involve the template elementi which was obviously a blocker.

    We are currently deciding on the best API for this, I kinda have a POC for one API and I'm building another POC for a different (imho slightly better API). It's coming! 😁

  9. gornostay25 commented on Apr 30, 2025

    @gornostay25

    any updates?

  10. paoloricciuti commented on Apr 30, 2025

    @paoloricciuti
    Member

    any updates?

    https://bsky.app/profile/paolo.ricciuti.me/post/3lnxnejj6mc2k

    Is shaping up, I was able to actually render a svelte component in Lynx...however there's still a lot of work to do 😊

  11. 3xau1o commented on Jul 13, 2025

    @3xau1o
  12. Prajwalg19 commented on Oct 5, 2025

    @Prajwalg19
  13. benmccann commented on Oct 5, 2025

    @benmccann
    MemberAuthor

    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.

  14. Antonio-Bennett commented on Oct 13, 2025

    @Antonio-Bennett
    Contributor

    @benmccann at what point is this not what the open collective is for? There are many individuals in the community that feasibly can't say hey big company let me pay you for this feature but have been donating to the open collective in hopes that the money will be put towards furthering the framework. Whether that may be sponsoring people to work or other things. There is likely not a big player that has been using svelte for native because the case has never been made prior to something like this coming along so I doubt it'll ever move along if you're looking for something like that. That's just my opinion.

  15. Prajwalg19 commented on Oct 13, 2025

    @Prajwalg19

    That's a valid point but i have been following paolo and he's been very busy with things like mcp for svelte, sveltelabs, hosting the svelte podcast and weekly youtube videos, patching bugs in svelte. So I think he's out of time to work on the custom renderer and might pick it up once all these major changes in svelte/sveltekit ecosystem becomes somewhat stable(remote functions, async svelte) assuming he gets to work on it. I just checked upon if he was parallelly in anyway working on custom render (which he isn't currently). I agree with you on the Open collective point. They should put this somewhere in the docs rephrasing it to indicate donations would speed up getting svelte native apps sooner than expected.

  16. Antonio-Bennett commented on Oct 13, 2025

    @Antonio-Bennett
    Contributor

    @Prajwalg19 I'm in no way criticizing Paolo, he's a goat and definitely appreciate all the things he's doing! But the phrasing has become sponsor his work via mainmatter to get this done so why not do that with the funds the community has been giving. Maybe there should be a voting system or something on what the funds should be spent towards if the maintainers see a need for specific goals to be sponsored

  17. delordemm1 commented on Jan 9, 2026

    @delordemm1
  18. vexkiddy commented on Jan 27, 2026

    @vexkiddy
  19. fvarano commented on Mar 5, 2026

    @fvarano
    Contributor

    Hi!
    Writing here just to chime in on the conversation, I've seen @paoloricciuti talk more about this topic recently, and the challenges needing to be faced for this feature.

    I'm curious about the approach taken, in particular i'm thinking how Svelte can support custom renderers without locking itself out of possible optimizations (for example the template one that Paolo mentioned on the Syntax.fm podcast).

    Apart from other JS frameworks' prior art, like Vue and SolidJS, there is the Leptos implementation that I think has a great design, and allows for these kind of optimizations, while keeping a pluggable renderer architecture: Tachys.

    For example, the RenderHtml trait specifically supports that use case, and even defines the hydration method.
    Greg talks about the core of this idea and how it enabled custom renderers for Leptos in this issue.

    Hope it helps!

  20. benmccann commented on Apr 2, 2026

    @benmccann
    MemberAuthor

    @farfromrefug I wanted to make sure you saw there is a PR to add custom renderer support to Svelte 5: #18042

    It should let you update https://github.com/nativescript-community/svelte-native to Svelte 5. It would be nice to open up a tracking issue in that repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions