GithubHelp home page GithubHelp logo

renderToString vs renderToStream about nuxt.js HOT 10 CLOSED

nuxt avatar nuxt commented on August 26, 2024
renderToString vs renderToStream

from nuxt.js.

Comments (10)

Atinux avatar Atinux commented on August 26, 2024 21

It will be implemented before the 1.0.0 👍

from nuxt.js.

jiangfengming avatar jiangfengming commented on August 26, 2024 15

I think providing a stream handler callback will be very useful.

Consider the following scenario:

nuxt-hook

Although Vue.js has a component based cache mechanism, it has several problems:

  • Still need to enter the render process.
  • Too complicated. One URL corresponding to one cached html file is more straightforward.

So I want to implement a vue independent cache system. If Nuxt could provide a hook to let me handle the stream, It will be very nice!

from nuxt.js.

pi0 avatar pi0 commented on August 26, 2024 2

Good to mention that according to vue ssr docs streaming is not recommended as we need to evaluate all async components in order to prepare complete headers. So it may introduce performance downsides! (This is actually not opposite to @fenivana's approach since it is streaming the cached response not during response generation :)) )

Since a lot of the context information (like head information or inlined critical CSS) needs to be appear before the application markup, we essentially have to wait until the stream to complete before we can start making use of these context data.

It is therefore NOT recommended to use streaming mode if you rely on context data populated by component lifecycle hooks.

from nuxt.js.

Atinux avatar Atinux commented on August 26, 2024 1

It was actually to make the code more easy to read and to start with (mostly for the renderRoute function).

Now that Nuxt.js will be soon released in V1, I don't see any inconvenient to use the streams to send back the HTML to the server!

from nuxt.js.

f15gdsy avatar f15gdsy commented on August 26, 2024

Awesome! This mechanism is very helpful for websites with many user-generated-pages!

from nuxt.js.

slrohit avatar slrohit commented on August 26, 2024

How to build rest apis in nuxt js,
let say i have a form, i wanted to store from data to database using a rest api, how do i achive this

from nuxt.js.

f15gdsy avatar f15gdsy commented on August 26, 2024

@slrohit This is out of the job scope of NUXT. NUXT should be just about server-side rendering.

API should be implemented in a separate server, or a middleware if you are using NUXT as a middleware.

from nuxt.js.

dohomi avatar dohomi commented on August 26, 2024

@slrohit I recently used https://github.com/zeit/micro for building a rest api, maybe have a look at that repo. Your usecase has nothing to do with NUXT as @f15gdsy mentioned above.

from nuxt.js.

piglovesyou avatar piglovesyou commented on August 26, 2024

v1.0 seems to be released soon. Where should I see to know actually Nuxt.js makes use of streaming SSR?

from nuxt.js.

lock avatar lock commented on August 26, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from nuxt.js.

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.