public-ui / kolibri

The accessible HTML-Standard
https://public-ui.github.io
European Union Public License 1.2
174 stars 34 forks source link

Pilot: Next.js + KoliBri real SSR #5506

Open sdvg opened 1 year ago

sdvg commented 1 year ago

Bitte das Samples (Mono-Repo, wenn mehr als 1) in folgendes Repo pushen: https://github.com/public-ui/lab-ssr-stencil

sdvg commented 1 year ago

Meine Erkenntnisse bzw. Notizen bis jetzt:

Ausgangslage

Lösungsansätze

import React from 'react';
import { renderToString } from '@public-ui/hydrate';

export const Kolibri = async ({children}: {children: string}) => {
    const START_TAG = `<kolibri-canvas>`
    const END_TAG = `</kolibri-canvas>`
    const htmlToRender = `${START_TAG}${children}${END_TAG}`
    const hydratedHtml = (await renderToString(htmlToRender)).html
    const matches = hydratedHtml.match(new RegExp(`${START_TAG}(.*)${END_TAG}`, 's'));
    return <div dangerouslySetInnerHTML={{ __html: matches?.[1] ?? '' }}></div>
}

Sonstige/allgemeine Probleme:

Mögliche nächste Schritte:

deleonio commented 11 months ago

See https://github.com/ionic-team/stencil/issues/4389

deleonio commented 11 months ago

🎅 @sdvg NTK - https://designsystem.porsche.com/v3/developing/next-js/ssr-support read SSR

deleonio commented 1 month ago

Nice to know: https://github.com/ionic-team/stencil-site/pull/1490