fastify / fastify-vite

Fastify plugin for Vite integration
MIT License
894 stars 75 forks source link

[SPA] allowing passing additional context to the render function #140

Open felixmosh opened 9 months ago

felixmosh commented 9 months ago

Prerequisites

🚀 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
});
Shyam-Chen commented 9 months ago

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

felixmosh commented 9 months ago

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

galvez commented 9 months ago

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.