April 2025posted on 04.06.2025import.meta import.meta is an object that is available within Javascript ES modules. It contains metadata about the module and is extensible. It contains import.meta.url that returns the full URL of the module. <script type="module" src="module.mjs"></script> // module.mjs let img = document.createElement('img'); img.src = new URL('image.jpg', import.meta.url); document.body.appendChild(img); Difference from process.env process.env is specific to Node and cannot be used in the browser. TypeScript support interface ImportMeta { myVariable: string } import.meta.myVariable; // string Uses Vite extend import.meta to add things like: Env Variables: import.meta.env. Glob Import: import.meta.glob No reactions yet
import.meta
import.meta is an object that is available within Javascript ES modules. It contains metadata about the module and is extensible.
It contains
import.meta.urlthat returns the full URL of the module.Difference from process.env
process.envis specific to Node and cannot be used in the browser.TypeScript support
Uses
Vite extend
import.metato add things like:import.meta.env.import.meta.glob