
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@local-logic/sdks-js
Advanced tools
Local Logic SDKs JS provides access to the next generation of Local Logic web SDKs.
Local Logic SDKs JS provides access to the next generation of Local Logic web SDKs.
First, install with yarn, pnpm, or npm:
yarn add @local-logic/sdks-js
pnpm add @local-logic/sdks-js
npm i --save @local-logic/sdks-js
The script is also available in umd and es format from the Local Logic CDN:
https://sdk.locallogic.co/sdks-js/<VERSION>/index.<FORMAT>.js
You can now import LocalLogicSDK:
import LocalLogicSDK from "@local-logic/sdks-js";
const ll = LocalLogicSDK("<API_KEY>");
âšī¸ Your
API_KEYshould be provided to you by a Local Logic team member.
With the instance of LocalLogicSDK, you are now free to create new widgets:
// Code from previous step
// ...
/**
* Create a container HTMLElement
*/
const container = document.createElement("div");
container.style.cssText = `
height: 100vh;
width: 100vw;
display: flex;
`;
document.body.appendChild(container);
// Render Local Content into the container
ll.create("local-content", container, {
lat: 45.52859,
lng: -73.58785,
marker: {
lat: 45.52859,
lng: -73.58785,
},
});
The SDKs are configured with Browserslist and @vitejs/plugin-legacy to support these browsers.
The SDKs will only serve polyfilled chunks only in legacy browsers without native ESM support. This keeps bundle sizes small for modern browsers.
LocalLogicSDKLocalLogicSDK instance provides global config options and methods.
LocalLogicSDK(apiKey, options)
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
apiKey | true | string | ApiKey required for making requests to the Local Logic API. | |
options.appearance | false | AppearanceAPI | The appearance option provides theme and variable support customizing the look and feel of your widgets. | |
options.locale | false | "en" | "fr" | "en" | The locale option specifies the language of the scores and the UI interface. |
localLogicSDK.createThe create method is used to render new widget instances.
localLogicSDK.create(sdkType, container, options, renderOptions)
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
sdkType | true | "local-content" | "demographics" | The SDK you would like to create. | |
container | true | HTMLElement | The element to render in to. | |
options | true | object | Options required for te specified sdkType. Options for each SDK are detailed below. | |
options.lat | true | number | Initial viewport latitude. | |
options.lng | true | number | Initial viewport longitude. | |
renderOptions.lazy | false | number | true | If true, the SDK will only load content when it scrolls into the viewport. |
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
zoom | false | number | 16 | Initial viewport zoom. |
pitch | false | number | 0 | Initial viewport pitch. |
bearing | false | number | 0 | Initial viewport bearing. |
cooperativeGestures | false | boolean | true | If true, scroll zoom will require pressing the ctrl or â key while scrolling to zoom map, and touch pan will require using two fingers while panning to move the map. |
marker | false | { lat: number; lng: number; icon?: "pin" | "house" } | If provided, will render Local Content using a pin marker. The marker can be used to symbolize a location being analyzed. This value is typically the same as the lat and lng. | |
distanceUnit | false | "metric" | "imperial" | metric | Primarily used for the commute calculator. Will display the distance in mi/yd under the imperial system or km/m under the metric system. |
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
title | false | boolean | string | "Local Demographics" | Setting the title to a string will replace the localized internal title. Setting the title to false will hide the title altogether. If you choose to set your own string, ensure you are sending the correct string when the locale changes. |
localLogicSDK.onThe on method takes a callback which is triggered when create options when an event occurs.
localLogicSDK.on(event, callback)
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
event | true | "change" | The name of the event. | |
callback | true | ({ type: string, data: unknown }) | The callback to be triggered when the specified event occurs. |
localLogicSDK.destroyThe destroy method is used to teardown the created SDK.
localLogicSDK.updateThe update method is used to update the widget with new values. This can be useful when, for example, you want to change the widget location.
localLogicSDK.update(options)
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
options.lat | true | number | Initial viewport latitude. | |
options.lng | true | number | Initial viewport longitude. | |
options.zoom | false | number | 16 | Initial viewport zoom. |
options.pitch | false | number | Initial viewport pitch. | |
options.bearing | false | number | Initial viewport bearing. | |
options.cooperativeGestures | false | boolean | true | If true, scroll zoom will require pressing the ctrl or â key while scrolling to zoom map, and touch pan will require using two fingers while panning to move the map. |
options.marker | false | { lat: number; lng: number; icon?: "pin" | "house"} | If provided, will render Local Content using a pin marker. The marker can be used to symbolize a location being analyzed. This value is typically the same as the lat and lng. | |
distanceUnit | false | "metric" | "imperial" | metric | Primarily used for the commute calculator. Will display the distance in mi/yd under the imperial system or km/m under the metric system. |
Local Logic SDKs JS comes packaged with TypeScript declarations.
FAQs
Local Logic SDKs JS provides access to the next generation of Local Logic web SDKs.
The npm package @local-logic/sdks-js receives a total of 2,699 weekly downloads. As such, @local-logic/sdks-js popularity was classified as popular.
We found that @local-logic/sdks-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.