New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

astro-variables

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-variables

A package for managing variables between server and client in Astro projects

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

astro-variables

This is an Astro integration that manages variables between server and client in Astro projects.

Usage

Prerequisites

TODO:

Installation

Install the integration automatically using the Astro CLI:

pnpm astro add astro-variables
npx astro add astro-variables
yarn astro add astro-variables

Or install it manually:

  • Install the required dependencies
pnpm add astro-variables
npm install astro-variables
yarn add astro-variables
  • Add the integration to your astro config
+import variables from "astro-variables";

export default defineConfig({
  integrations: [
+    variables(),
  ],
});
  • Add middleware
import { defineVariables } from "astro-variables";
import { sequence } from "astro:middleware";

const variables = defineVariables(async () => {
  return {
    hello: "Hello World",
    count: 1,
  };
});

export const onRequest = sequence(variables /** ...other middlewares */);
  • Use the variables in your components
---
import variables from 'astro:variables';

// Access the variables in your server-side code:

console.log(variables.hello, variables.count); // Get value by property
console.log(variables()); // Execute the function to get all variables
---

<p>Hello: {variables.hello}</p>
<p>Count: {variables.count}</p>
<p>All: {JSON.stringify(variables())}</p>

<script>
  // Access the variables in your client-side code:
  import variables from 'astro:variables';

  console.log(variables.hello, variables.count); // Get value by property
  console.log(variables()); // Execute the function to get all variables
</script>

## Contributing

This package is structured as a monorepo:

- `playground` contains code for testing the package
- `package` contains the actual package

Install dependencies using pnpm:

```bash
pnpm i --frozen-lockfile

Start the playground and package watcher:

pnpm dev

You can now edit files in package. Please note that making changes to those files may require restarting the playground dev server.

Licensing

MIT Licensed. Made with ❤️ by varHarrie.

Acknowledgements

Keywords

astro-integration

FAQs

Package last updated on 29 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts