Skip to main content
Once users fill out your configuration form, the data is stored in salesive.config.json. This guide shows you how to access and use these variables in your theme.

Configuration File Structure

When a user submits your form, their data is saved to salesive.config.json:

Variable Structure

All form field values are stored in the variables object, using the field id as the key:

Accessing Variables

Salesive provides the salesive-dev-tools package for accessing configuration variables in your React themes.

Installation

Install the package in your theme project:

Setup

1. Configure Vite Plugin

Add the Salesive config plugin to your vite.config.js:
The plugin automatically injects your config into the application during development.

2. Create Configuration File

Your salesive.config.json file should be in the project root with variables from the form:

Using Variables in React Components

Using the React Hook

The useSalesiveConfig hook is the primary way to access variables in React components:

Getting All Variables

You can also retrieve all variables at once:

Using in Non-Component Code

For accessing config outside of React components, use the helper function:

Dynamic Configuration Updates

Update configuration values at runtime and all components will automatically re-render:
All components using useSalesiveConfig will automatically update when configuration changes.

CSS Variables

The plugin automatically injects all variables as CSS custom properties:
Or use the auto-injected CSS variables directly:

Variable Types and Usage

Text Variables

Use text variables for content throughout your theme:

Media Variables

Single Image

Multiple Images (Array)

Color Variables

Use color variables for theming:
Or use CSS with auto-injected variables:

Select Variables

Single Select

Multi Select (Array)

Default Values

Always provide fallback values in case a variable is not set:

Complete Example

Here’s a complete example showing how to use various variable types:

Best Practices

Always Provide DefaultsNever assume a variable will be set. Always provide fallback values to prevent broken layouts when variables are missing.
Sanitize User InputIf displaying user-provided text or URLs, sanitize the input to prevent XSS attacks, especially for HTML rendering.
Variable Naming
  • Use descriptive, semantic names: heroTitle instead of title1
  • Follow camelCase convention: primaryColor, phoneNumber
  • Be consistent across your entire theme
  • Document which variables are required vs optional

Testing Variables

Development Testing

Create a test salesive.config.json with sample data:

Production Validation

Before deploying your theme:
  1. Test with minimal required variables only
  2. Test with all variables filled
  3. Test with very long text values
  4. Test with special characters in text fields
  5. Test with various image sizes and formats
  6. Test with all possible select option combinations

Variable Documentation

Document your theme’s variables in a README.md:
This helps users understand what each variable does and which ones are required.

Next Steps

View Examples

See complete examples of form schemas and their usage

Schema Structure

Review the complete schema structure reference