fastify-vite icon indicating copy to clipboard operation
fastify-vite copied to clipboard

Allowing passing additional context to the html function in spa mode

Open felixmosh opened this issue 1 year ago • 3 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Currently SPA mode doesn't allows to pass additional context to the render function.

Motivation

I have a case that I wan't to render some stuff on the html not related to the React app.

For example, render app version inside a meta tag.

Example

reply.html({
      version: env.BUILD_VERSION
});

felixmosh avatar Mar 05 '24 09:03 felixmosh

Use https://vitejs.dev/config/#using-environment-variables-in-config?

Shyam-Chen avatar Mar 06 '24 01:03 Shyam-Chen

Will it work inside the HTML? (In my case, I need it to be dynamic depending on the domain the app got served from)

felixmosh avatar Mar 06 '24 03:03 felixmosh

As long as it's prefixed with VITE_, it will be picked up by Vite automatically.

But this feature request is very much worthwhile, I'll look into it and circle back.

galvez avatar Mar 06 '24 12:03 galvez