+
Skip to content

feat(vite-plugin-nitro): support static server side data fetching during prerendering #1771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

brandonroberts
Copy link
Member

PR Checklist

Closes #1762

What is the new behavior?

When using Server-Side Data Fetching, the data is cached and reused using transfer state only on the first request. To prerender the server-side data fetched along with the route, set the staticData flag to true in the config object for the prerendered route.

For example, a route defined as src/app/pages/shipping.page.ts with an associated src/app/pages/shipping.server.ts has the route and server data prerendered to be completely static.

import { defineConfig } from 'vite';
import analog from '@analogjs/platform';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
  plugins: [
    analog({
      static: true,
      prerender: {
        routes: async () => [
          '/',
          { 
            route: '/shipping',
            staticData: true
          }
        ],
      }
    }),
  ],
}));

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

[optional] What gif best describes this PR or how it makes you feel?

Copy link

netlify bot commented Jun 9, 2025

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit 79bc60e
🔍 Latest deploy log https://app.netlify.com/projects/analog-docs/deploys/68464c99e308020008ffb495
😎 Deploy Preview https://deploy-preview-1771--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jun 9, 2025

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit 79bc60e
🔍 Latest deploy log https://app.netlify.com/projects/analog-blog/deploys/68464c990cad29000884effd
😎 Deploy Preview https://deploy-preview-1771--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jun 9, 2025

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit 79bc60e
🔍 Latest deploy log https://app.netlify.com/projects/analog-app/deploys/68464c9910b26b0008d26ab2
😎 Deploy Preview https://deploy-preview-1771--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jun 9, 2025

Deploy Preview for analog-ng-app ready!

Name Link
🔨 Latest commit 79bc60e
🔍 Latest deploy log https://app.netlify.com/projects/analog-ng-app/deploys/68464c9a5816230008e5652f
😎 Deploy Preview https://deploy-preview-1771--analog-ng-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@brandonroberts brandonroberts merged commit 377cdd2 into beta Jun 13, 2025
22 checks passed
@brandonroberts brandonroberts deleted the feat-prerender-static-data branch June 13, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Keeping Cached Server Side Data
1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载