question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending prerender routes

See original GitHub issue

In Nuxt 2, using nuxt generate, we could either manually provide routes to generate or depend on the (later added) crawler to find them.

For manual mode, it was possible to use generate.routes option to provide an async function prefetching them. While this functionality is needed in general, adding async logic to nuxt.config is kinda an anti pattern that we are trying to avoid in Nuxt 3 so there might be better ideas.

Ref: #4885

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:26 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
pi0commented, May 11, 2022

@TotomInc As a workaround, You can also use nitro:config hook to add custom (async) routes to prerenderer:

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  hooks: {
    async 'nitro:config' (nitroConfig) {
      if (nitroConfig.dev) { return }
      // ..Async logic..
      nitroConfig.prerender.routes.push('/custom')
    }
  }
})
4reactions
dwin94commented, Oct 7, 2022

I think there’s a misunderstanding. We are not talking about query parameters. The feature we are referring to is this one: https://nuxtjs.org/docs/configuration-glossary/configuration-generate/#speeding-up-dynamic-route-generation-with-payload

nuxt.config.js:

export default {
  generate: {
    routes() {
      // 1) fetch data from CMS
      // 2) pass page data directly to each of the pages

      return [
        { route: '/', payload: { title: 'Home', headerImageUrl: '...' } }
        { route: '/about-us', payload: { title: 'About us', headerImageUrl: '...' } }
      ]
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Prerendering static pages - Angular
Provide extra routes in the command line; Provide routes using a file; Prerender specific routes. Provide extra routes in the command linelink. While...
Read more >
Page options • Docs • SvelteKit
The prerenderer will start at the root of your app and generate files for any prerenderable pages or +server.js routes it finds. Each...
Read more >
Angular universal : Unable to prerendering dynamic routes
There are many categories under my primary route, so I need this dynamic prerendering. How to set this type of data under prerender...
Read more >
Prerendering methods and data fetching strategies in JSS ...
The GetStaticPaths implementation generates a list of paths that must ... When creating a JSS Next.js app specifying --prerender SSR , the ...
Read more >
Angular Universal Example: Server Side Rendering (SSR ...
Angular Universal Example: Server Side Rendering (SSR), Prerender · 1. Getting started with Angular 10 · 2. Routing and HttpClient implementation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found