
Nuxt SSR & SSG
Server-side rendering, static generation, hybrid rendering, prerendering, route rules, nitro
1What is Server-Side Rendering (SSR) in Nuxt?
What is Server-Side Rendering (SSR) in Nuxt?
回答
SSR generates the complete HTML on the server with each request, then sends it to the client. This improves SEO as search engines receive immediately accessible HTML content, and also improves time to first paint. SSR is the default rendering mode in Nuxt 3, unlike client-side rendering where JavaScript generates content in the browser.
2What is Static Site Generation (SSG) in Nuxt?
What is Static Site Generation (SSG) in Nuxt?
回答
SSG generates all pages as static HTML at build time, allowing pre-generated files to be served very quickly. This approach is ideal for sites with content that doesn't change often, like blogs or documentation. In Nuxt 3, using nuxt generate activates SSG, creating HTML files for each configured route.
3Which Nuxt command should be used to generate a static site?
Which Nuxt command should be used to generate a static site?
回答
The nuxt generate command (or npm run generate if configured in package.json) triggers static generation of all pages. Nuxt traverses routes and creates an HTML file for each, which is placed in the .output/public folder. This command is used to deploy on static hosts like Netlify, Vercel or GitHub Pages.
What is the main advantage of SSR for SEO?
What is hybrid rendering in Nuxt?
+19 面接問題