Skip to content
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

Nitro: Provide better API for client-only rendering when using SSR #810

Closed
2 tasks
brandonroberts opened this issue Dec 20, 2023 · 1 comment
Closed
2 tasks
Labels
enhancement New feature or request

Comments

@brandonroberts
Copy link
Member

Which scope/s are relevant/related to the feature request?

vite-plugin-nitro

Information

There was a use case brought up in Discord about supporting client-only sections of the app. As an example, every URL under the /admin path should not go through SSR, but should just return the index.html.

Describe any alternatives/workarounds you're currently using

Use the main.server.ts to eagerly return the document for certain paths

export default async function render(url: string, document: string) {
  // client-render any admin URLs
  if(url.includes('admin')) {
    return Promise.resolve(document);
  }

  // Server-render anything that's not prerendered
  const html = await renderApplication(bootstrap, {
    document,
    url,
  });

  return html;
}

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@brandonroberts brandonroberts added the enhancement New feature or request label Dec 20, 2023
@brandonroberts brandonroberts changed the title Nitro: Provide better API for client-only rendering Nitro: Provide better API for client-only rendering when using SSR Dec 20, 2023
@brandonroberts
Copy link
Member Author

Closed in #1011 where disabling SSR will still produce the same output but render the app only on the client-side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant