Coder Social home page Coder Social logo

Comments (11)

KevinMind avatar KevinMind commented on June 2, 2024 5

I've implemented next.js as a template service for node-tailor

you use next.js to generate your pages with server rendered html.

inside these pages you render components which when processed through tailor on server side, are replaced with your fragment applications (which are probably just CRA or simple smaller applications that don't need all the things next.js provides.

Building FRAGMENTS with next.js feels like an anti-pattern, because next.js is designed to be a framework which handles rendering pages.

That's one of the most powerful features of tailor though, it can process anything that can return *

I can provide an example if this is still interesting for anyone.

from tailor.

stevoPerisic avatar stevoPerisic commented on June 2, 2024 1

After taking a look over the NextJS docs it seems that you can create and serve server-side rendered components without the HTML page document artifacts (like the head tag). All you have to do is remove this from the service that runs a particular component:

import Document, { Head, Main, NextScript } from 'next/document'

I would create a "layout" service that actually does the Document import to create the base-template and any other sub-templates that your application might need. Then create separate services that return server-side rendered components (fragments) to use in laying out the interior of the templates.

Hope that makes sense, I'm happy to chat more about it.

from tailor.

rorofino avatar rorofino commented on June 2, 2024

Also interested.

from tailor.

stevoPerisic avatar stevoPerisic commented on June 2, 2024

from tailor.

rorofino avatar rorofino commented on June 2, 2024

I think NextJS needs to handle the whole page render.
Do you know if it is possible to use it to generate only the HTML of fragments?

from tailor.

stevoPerisic avatar stevoPerisic commented on June 2, 2024

from tailor.

rorofino avatar rorofino commented on June 2, 2024

Thanks for the Help @stevoPerisic !

I dont think NextJS can serve a response without the whole HTML page. (doc, head, body, etc...).

from tailor.

stevoPerisic avatar stevoPerisic commented on June 2, 2024

from tailor.

joriswijlens avatar joriswijlens commented on June 2, 2024

Hi,

It works quite well until you have two fragments of the same application on the same page. I think this is due to the fact that both fragments load js files with the same name. I created a test with a page that renders two fragments with simple text: fragment 1 and fragment 2. After the second fragment loads they both say fragment 2.

from tailor.

kirankalyan5 avatar kirankalyan5 commented on June 2, 2024

Also interested in the outcome and possibilities.

Thanks

from tailor.

lsrocha avatar lsrocha commented on June 2, 2024

@KevinMind Could you share how did you use node-tailor with Next.js? I'm very interested in developing an application using both.

Did you import tailor into Next.js project or run both standalone? Do you have any project running in production?

from tailor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.