Comments (2)
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.
There is an example of ssr but in hybrids reppo issues :)
hybridsjs/hybrids#24 (comment)
from skatejs.
Related Issues (20)
- First sentence in README.md is not correct HOT 2
- CLI command is actually "skatejs" not "skate" HOT 2
- SkateJS ssr example just not working HOT 1
- How to submit a v5 bug fix? HOT 1
- [bug] Every skate element gains property getters/setters of all other skate element. HOT 3
- Module build coming out CJS. HOT 3
- Add docs how to handle attribute update scenario HOT 1
- @skatejs/element-react "Invalid component name" error on WebComponent disconnectedCallback
- Using `ReactDom.render` many many times is slow HOT 2
- Homepage is broken HOT 1
- @skatejs/element should export ES6 class rather than compiled one
- Check if object is a Skate Element and Get Properties HOT 1
- SSR throws error when first childNode is a web component HOT 2
- SSR: rendered Light DOM placement HOT 2
- SSR example not working?
- Jest env not working in Jest 27 HOT 1
- Todo List example is not found
- SSR demo in readme does not work HOT 1
- element-redom
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skatejs.