Skip to main content

Package Installation

Install Rule Engine JS using your preferred package manager:
npm install rule-engine-js

Verify Installation

After installation, verify that the package is correctly installed:
import { createRuleEngine } from 'rule-engine-js';

const engine = createRuleEngine();
console.log('Rule Engine JS installed successfully!');

Import Methods

Rule Engine JS supports multiple import formats:

TypeScript Support

Rule Engine JS includes TypeScript type definitions out of the box. No additional @types package is needed.
import { createRuleEngine, RuleEngine, RuleExpression } from 'rule-engine-js';

const engine: RuleEngine = createRuleEngine();

const rule: RuleExpression = {
  and: [
    { gte: ['age', 18] },
    { eq: ['role', 'admin'] }
  ]
};

const result = engine.evaluateExpr(rule, { age: 25, role: 'admin' });

Browser Compatibility

Rule Engine JS works in all modern browsers that support ES6. For older browsers, use a transpiler like Babel.

Minimum Browser Versions

  • Chrome: 60+
  • Firefox: 60+
  • Safari: 12+
  • Edge: 79+

Browser Bundle

For browser usage, use the pre-built UMD bundle:
<!-- Development -->
<script src="https://unpkg.com/rule-engine-js/dist/index.js"></script>

<!-- Production (minified) -->
<script src="https://unpkg.com/rule-engine-js/dist/index.min.js"></script>

Node.js Compatibility

Rule Engine JS supports Node.js versions 16 and above.

Minimum Node.js Versions

  • Node.js: 16.x, 18.x, 20.x, 22.x+
  • Recommended: 18.x or higher

Framework Integration

React

Works seamlessly with React applications. Use hooks for reactive rule evaluation.

Vue

Compatible with Vue 2 and Vue 3. Use computed properties for reactive rules.

Angular

Integrates with Angular services and dependency injection.

Express

Perfect for server-side validation and middleware logic.

Bundle Sizes

Rule Engine JS is designed to be lightweight:
FormatSizeGzipped
ESM~45KB~12KB
UMD~48KB~13KB
UMD (minified)~22KB~8KB
Use the ESM format for tree-shaking and optimal bundle size in modern build tools.

Development Dependencies

No additional dependencies are required for Rule Engine JS itself. However, for development you might want:
npm install --save-dev jest @types/jest
Rule Engine JS is designed to be easily testable with any testing framework.
npm install --save-dev typescript @types/node
Type definitions are included in the package, but you’ll need the TypeScript compiler for development.
npm install --save-dev eslint prettier
Standard JavaScript linting tools work great with Rule Engine JS code.

Next Steps