Git Product home page Git Product logo

Comments (5)

usabir-mms avatar usabir-mms commented on September 24, 2024 1

Hi @tahuy
I was able to solve it by initializing the useSSE hook inside my parent NextJS application and passing the initialized variable as PROP to my react based library components. Then, inside my react components, I used this prop based useSSE to make double SSR rendering. However, this was not the ideal approach in an enterprise level application as this architecture failed to work in parallel with getStaticProps and getServerSideProps on other pages. With this double-ssr approach, you are bound to implement the entire web application using this architecture. You cannot leverage the existing data fetching capabilities of NextJS for SSR and SSG. As a workaround, I wrote a data generator inside my components library and called that function to fetch data for my desired component and passed it as normal props from my parent NextJS application.
Fortunately, nothing to worry about. You can now 100% achieve the component based data fetching, thanks to the newly launched NextJS v13. This is currently still in BETA but will definitely be a game changer. Follow this link to know more: https://beta.nextjs.org/docs/data-fetching/fundamentals#component-level-data-fetching

With this architecture, you can now implement data fetching logic directly inside your layouts.

from usesse.

usabir-mms avatar usabir-mms commented on September 24, 2024

@kmoskwiak Please respond to my query as this is really urgent

from usesse.

tahuy avatar tahuy commented on September 24, 2024

Hi @usabir-mms
How is your solution for this?
I read from this post, maybe it solve your problem.
If you have another way to handle it, please tell me. I'm facing same problem

from usesse.

jamesopti avatar jamesopti commented on September 24, 2024

@usabir-mms Do NextJS 13 layouts make this useSSE technique unnecessary?

from usesse.

tahuy avatar tahuy commented on September 24, 2024

Hi @tahuy

I was able to solve it by initializing the useSSE hook inside my parent NextJS application and passing the initialized variable as PROP to my react based library components. Then, inside my react components, I used this prop based useSSE to make double SSR rendering. However, this was not the ideal approach in an enterprise level application as this architecture failed to work in parallel with getStaticProps and getServerSideProps on other pages. With this double-ssr approach, you are bound to implement the entire web application using this architecture. You cannot leverage the existing data fetching capabilities of NextJS for SSR and SSG. As a workaround, I wrote a data generator inside my components library and called that function to fetch data for my desired component and passed it as normal props from my parent NextJS application.

Fortunately, nothing to worry about. You can now 100% achieve the component based data fetching, thanks to the newly launched NextJS v13. This is currently still in BETA but will definitely be a game changer. Follow this link to know more: https://beta.nextjs.org/docs/data-fetching/fundamentals#component-level-data-fetching

With this architecture, you can now implement data fetching logic directly inside your layouts.

Hi @usabir-mms
Excellent, thank you so much

from usesse.

Related Issues (8)

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.