Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Can used next.js to server render Mithirl.js #2196

Closed
togoog opened this issue Jul 23, 2018 · 4 comments
Closed

Can used next.js to server render Mithirl.js #2196

togoog opened this issue Jul 23, 2018 · 4 comments
Labels
Type: Question For issues that are purely questions about Mithril, not necessarily bug reports or suggestions

Comments

@togoog
Copy link

togoog commented Jul 23, 2018

Would you like to ask if next.js can be used with mithril.js? Thank you!

@togoog togoog changed the title How with next.js to server render Mithirl.js Can used next.js to server render Mithirl.js Jul 23, 2018
@StephanHoyer
Copy link
Member

For server rendering there is mithril-node-render

@lhorie
Copy link
Member

lhorie commented Aug 22, 2018

Next.js is React-specific. Fusion.js can support Mithril though.

@dead-claudia dead-claudia added the Type: Question For issues that are purely questions about Mithril, not necessarily bug reports or suggestions label Oct 28, 2018
@josephspurrier
Copy link

On a semi-related note (and I know it's old) - @lhorie, do you have any samples of using Fusion.js with Mithril - specifically on routing? I've got the start, but I think it will require a plugin for the router otherwise it throws Cannot read property 'history' of undefined. Let me know if you want me to open a separate ticket (and which repo).

import App, { RenderToken } from 'fusion-core';

export default async function start() {
    // Allow Mithril to work with SSR.
    if (!global.window) {
        global.window = global.document = global.requestAnimationFrame = undefined
    }

    // Require mithril after setting window.
    var m = require('mithril');
    m.route.prefix = '';
    const mithrilrender = require('mithril-node-render');

    const render = el =>
        __NODE__
            ? mithrilrender(el)
            : m.render(document.getElementById('root'), el);

    const root = HomePage;
    const app = new App(root);
    app.register(RenderToken, render)
    return app;
}

export const HomePage = () => {
    var m = require('mithril');

    return {
        view: () =>
            m('div', [
                'Home page.',
                m(m.route.Link, { href: '/about' }, 'About')
            ]),
    };
};

@josephspurrier
Copy link

I did find a router for Mithril using the universal router and added a quick repo here of Mithril with Fusion.js: https://github.com/josephspurrier/mithril-fusion

@MithrilJS MithrilJS locked and limited conversation to collaborators Jan 29, 2022
@orbitbot orbitbot converted this issue into discussion #2730 Jan 29, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Type: Question For issues that are purely questions about Mithril, not necessarily bug reports or suggestions
Projects
None yet
Development

No branches or pull requests

5 participants