public-ui / kolibri

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

Pilot: Next.js + KoliBri real SSR #5506

Open sdvg opened 8 months ago

sdvg commented 8 months ago

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

sdvg commented 8 months 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 7 months ago

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

deleonio commented 7 months ago

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