SSR Example #544
Replies: 3 comments 3 replies
-
Hi @maxwaiyaki, Alpine doesn't have any SSR support since the original design idea / philosophy was to use it with your existing server side / rendered markup. Just sprinkling bits of reactivity on top. Since then |
Beta Was this translation helpful? Give feedback.
-
This is what I am doing for SSR (using JSDOM), it is rather clunky though. Object.assign(global, { navigator: new JSDOM().window.navigator });
Object.assign(global, { MutationObserver: class { observe() {} } });
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Alpine = require("alpinejs");
const xml = fs.readFileSync(__dirname + "/../test/simple.xml");
const { window } = new JSDOM(xml, { contentType: "application/xml" });
Object.assign(global, { window, document: window });
const el = window.document.documentElement;
Alpine.initializeComponent(el, {}); |
Beta Was this translation helpful? Give feedback.
-
I've just released Alpinejs SSR which is simple to use and also supports Alpine.js hydration/interactivity after server-side-rendering. |
Beta Was this translation helpful? Give feedback.
-
Is there an SSR example for Alpine.js??
Beta Was this translation helpful? Give feedback.
All reactions