Skip to main content

Package

Package

To get started with the installation, run:

npm i @elbwalker/walker.js

Then run the following code once to create an instance:

import { createSourceWalkerjs } from '@elbwalker/walker.js';

const { elb, instance } = createSourceWalkerjs({
/* custom config */
});

elb

To configure and communicate with the walker.js instance asynchronously either load the elb-helper function:

import { elb } from '@elbwalker/walker.js';

Or define the elb-helper function yourself:

// Typescript
import type { Elb } from '@elbwalker/walker.js';
const elb: Elb.Fn = (...args: unknown[]) => {
(window.elbLayer = window.elbLayer || []).push(args);
};

// JavaScript
function elb() {
(window.elbLayer = window.elbLayer || []).push(arguments);
}

or use the elb returned from createSourceWalkerjs which returns the async result of the call:

const { elb } = createSourceWalkerjs();
await elb('entity action');

Single Page Applications

When using a Single Page Application like React, tell the walker to run on each location change in your app:

import React from 'react';
import { Route, Routes, useLocation } from 'react-router-dom';
import { createSourceWalkerjs } from '@elbwalker/walker.js';

const { elb } = createSourceWalkerjs({ default: true });

export default function App() {
const location = useLocation();
React.useEffect(() => {
elb('walker run'); // party hard!
}, [location]);

return <Routes>// ...</Routes>;
}
tip

Check out the detailed react example on Github.

info

If you need professional support with your walkerOS implementation, check out our services.