Umbraco.Community.ServerVariables
0.2.0
See the version list below for details.
dotnet add package Umbraco.Community.ServerVariables --version 0.2.0
NuGet\Install-Package Umbraco.Community.ServerVariables -Version 0.2.0
<PackageReference Include="Umbraco.Community.ServerVariables" Version="0.2.0" />
<PackageVersion Include="Umbraco.Community.ServerVariables" Version="0.2.0" />
<PackageReference Include="Umbraco.Community.ServerVariables" />
paket add Umbraco.Community.ServerVariables --version 0.2.0
#r "nuget: Umbraco.Community.ServerVariables, 0.2.0"
#:package Umbraco.Community.ServerVariables@0.2.0
#addin nuget:?package=Umbraco.Community.ServerVariables&version=0.2.0
#tool nuget:?package=Umbraco.Community.ServerVariables&version=0.2.0
Server Variables for Umbraco
This package reintroduces server variables in Umbraco 15+, which is a way to expose variables from C# to JavaScript.
What is it?
Server Variables was a thing up until Umbraco 13, where you could add variables to your site through the ServerVariablesParser.Parsing
notification and access them in the Backoffice through Umbraco.Sys.ServerVariables
. This was removed in Umbraco 14, but this package reintroduces the concept with a twist.
In short, this package gives you a simple way to expose server variables to your Umbraco Backoffice and/or Frontend. It allows you to add server variables to your site without having to write any or only a little code.
The variables are added through appsettings.json or through the IServerVariablesService
interface.
The twist is that the variables are made available through the importmap in the browser. This way, you can import the variables where you need them without having to rely on any global JavaScript objects. They will also work in the Frontend which is a big plus.
The variables are added either through appsettings.json or through the IServerVariablesService
interface and are accessed through an importmap in the browser:
import vars from 'vars';
console.log(vars); // { apiUrl: 'https://api.example.com' }
NB! Do not include any secrets in the server variables as they will be exposed to the public.
Requirements
- Umbraco 15 or higher
- .NET 9 or higher
Usage
See the documentation for more information on how to use the package:
Acknowledgements
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Umbraco.Cms.Web.Common (>= 15.2.2)
- Umbraco.Cms.Web.Website (>= 15.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.