GithubHelp home page GithubHelp logo

Comments (2)

treshugart avatar treshugart commented on May 24, 2024 4

Hey @matthewharwood. I've just committed some much-needed updates to the docs. Unfortunately, there isn't a good story for SSR when using web components inside a host framework like Preact or React. The SSR package works on something that is completely built in web components as it contains its own render() function that is like renderToString().

I am actively thinking about this, though, and think using a custom JSX pragma function could get us most of the way there. When SSR'ing with a framework in mind, you have to design the solution in just that way: tailored to the specific framework in mind. It also places restrictions on what your custom elements can implement inside render() as it will need to know how to turn it into a string. One idea I have here, is the ability to define a renderToString() method on the class itself. That way, each base class could implement this and the JSX pragma just needs to call them when transforming inside of a renderToString() call.

One major downside of SSR'ing like most frameworks do is that you sort of have to emulate shadow DOM CSS scoping somehow. Whether this is via CSS-in-JS or other means, it's necessary to fill the gap between TTFB (time to first byte) and when the custom element definitions upgrade the elements.

This may sound a bit nebulous at this point and that's because it's all in my head and I'm brain-dumping all the ideas I've been thinking about lately. Definitely happy to continue this conversation and flesh it out more if you're interested.

Again, apologies for not having a solution for other libraries yet, but I think we can get there eventually :)

Docs for skatejs/element updated at https://skatejs.netlify.com/docs/element.

from skatejs.

FDiskas avatar FDiskas commented on May 24, 2024 2

There is an example of ssr but in hybrids reppo issues :)
hybridsjs/hybrids#24 (comment)

from skatejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.