Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support server-side rendering #181

Open
JRJurman opened this issue Nov 8, 2021 · 2 comments
Open

Support server-side rendering #181

JRJurman opened this issue Nov 8, 2021 · 2 comments

Comments

@JRJurman
Copy link
Member

JRJurman commented Nov 8, 2021

Summary

In version 11 (#175), we lost support for server-side rendering (mostly an artifact of removing domino from nanohtml - Tram-One/nanohtml#20)

Ideally, we'd like to add this back in, with the support of the mutation observers that didn't quite exist before. This should be possible, but needs investigation.

@JRJurman
Copy link
Member Author

Without changing Tram-One, we could also scaffold runkit with jsdom (similarly, it might be possible to support server-side-rendering with jsdom). The following example works but could potentially be cleaned up:

const { JSDOM } = require("jsdom"); 
const { registerHtml } = require('tram-one');

const dom = new JSDOM();
global.document = dom.window.document;

const html = registerHtml();
const home = () => {
	return html`
		<main>
			<h1>Tram-One</h1>
			<h2>A Modern View Framework for Vanilla Javascript</h2>
		</main>
	`;
};

home().outerHTML

@JRJurman
Copy link
Member Author

JRJurman commented Jul 7, 2022

Note, simply making Tram-One work on the server will not be enough to make SSR work - we need to figure out how we want to do hydration of elements, and since so much of Tram-One is about embedding the state of elements in their nodes, decorating existing HTML may be difficult.

We may need to serve a minimal amount of JS that just adds attributes to a served HTML template 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant