Skip to content

A page re-rendering and page deletion composable #27058

Description

@chibx

Describe the feature

This request is for the implementation of a renderPage() method capable of calling the internal prerender process of Nuxt to render, not just normal pages, but those with dynamic slugs.
I believe this feature would prove significant for blogs, and various static sites to control the re-rendering of specific pages upon update to their respective data.

export default defineEventHandler(async (event)=>{
  await renderPage('/posts/24', { query1:  'mostLiked' });
});

The previous way of adding prerenderable slugs below results in the the need to rebuild to get fresh new routes/slugs:

import { ofetch } from 'ofetch';

const getPlanetsRoutes = async () => {
    const response = await ofetch("https://api.nuxtjs.dev/planets");
    return response.map((planet) => `/planets/${planet.slug}`);
}

export default defineNuxtConfig({
    hooks: {
        async 'nitro:config'(nitroConfig) {
            const planetsRoutes = await getPlanetsRoutes();
            nitroConfig.prerender.routes.push(...planetsRoutes);
        }
    }
});

This feature request prevents the need for unnecessary rebuild and allows re-rendering to occur server-side. This will improve flexibility and ease as anyone could cache a page based on data/[slug title] gotten from a database.
Developers will be able to delete pages that are no longer needed (maybe after deletion of data from a store) using removePage(route).

The feature would be added only for users with the prerender feature enabled on at least one route, so as to avoid rendering conflicts with a full SSR app rendering mechanism

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionnitroNitro server engine integration

    Fields

    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions