Environment variable scope and persistence limits with Hoppscotch collections
0 reputation · 17 May 2022, 09:13 UTC
0 reputation · 17 May 2022, 09:13 UTC
A repeatable API development workflow in Hoppscotch relies on environments for endpoint switching and collections for grouping related requests. The documented capability allows key-value environments for dev, staging and production, and collections can be exported and imported as JSON to share state across team members.
Persistence behavior is constrained by storage location. Environment variables can be stored in browser local storage and may be lost if cache is cleared without a synced account. Self-hosted deployments via Docker require manual backend and database configuration to ensure collections persist.
For a repeatable setup that moves between local browser sessions and a self-hosted instance, the scope of environment definitions relative to a collection is unclear.
34775 reputation · 17 May 2022, 17:57 UTC
Exported Hoppscotch collection JSON typically preserves variable references such as {{base_url}} inside request URLs, headers, and bodies, but does not embed the environment key-value definitions themselves. Environments are scoped to the workspace or account, not to an individual collection. When a collection is imported into a fresh unsigned browser session, environment values that are not already present in that browser’s storage resolve to empty strings or remain as unreplaced placeholders.
| Behavior | What happens | Verification note |
|---|---|---|
| Collection export | Contains request definitions and {{variable}} references; environment definitions are stored separately. | Open the exported JSON and search for an environments block. |
| Environment scope | Workspace- or account-level; one environment can be applied to multiple collections. | Check whether the same environment appears in the selector for different collections. |
| Fresh unsigned import | Missing environment values are not auto-created; requests send blanks or literal placeholders. | Import into a new unsigned profile and inspect the resolved request URL. |
| Persistence without account | Stored in browser storage such as IndexedDB or localStorage; cleared by browser data removal. | Export JSON before clearing site data; there is no built-in restore path otherwise. |
| Self-hosted Docker | Collections and environments can be lost on container recreation unless database volumes are mounted. | Compare data survival with and without mounted volumes. |
{{base_url}}.Open the exported collection file in a text editor. If you see only {{base_url}} references and no environment key-value block, the definitions must be moved separately. In a fresh unsigned browser profile, import the collection and check the Network panel or request preview to confirm whether variables resolve.
Assumption: this describes Hoppscotch web and desktop behavior around collection export and browser storage. Self-hosted builds may differ, and the exact export schema should be confirmed for your version before team-wide adoption.
Missing diagnostic detail: which Hoppscotch build and version are you using (web, desktop, or self-hosted)? This determines whether environment export is available and where persistence is configured.
Use comments to ask for clarification. Post a solution as an answer.
6,260 reputation · 17 May 2022, 19:15 UTC
It is important to clarify that in Hoppscotch (v2.x), collection exports do not include environment definitions. The exported JSON contains only the variable references (e.g., {{baseUrl}}). To share a functional setup with a teammate, you must export and share the environment JSON separately via the Environments panel.
Regarding resolution in fresh sessions without an account:
"{{baseUrl}}") as the literal value in the request.To verify this behavior, you can import a collection into an incognito window and observe the request headers; the variables will remain unresolved until a matching environment is manually created or synced.