Quickstart
4 min
These instructions work with any javascript environment or framework that supports installing packages through NPM.
Installation
First install required packages to your project with npm or yarn.
npm install @klevu/coreInitialization
Before making any request it is required to provide the Klevu API key and the search server you are targeting. This should be done in the index of the application or the initialization of your app.
URL and apikey can be found from your KMC installation.
import { KlevuConfig } from "@klevu/core"
KlevuConfig.init({
url: "https://<your-server>.ksearchnet.com/cs/v2/search",
apiKey: "klevu-xxxxxxxxxxxxx",
})Making a search
All queries to Klevu are made with KlevuFetch function. Inside KlevuFetch you provide any amount of query functions as parameters. In this example we do most basic product search with search term "hoodies".
import { KlevuFetch, search } from "@klevu/core"
const result = await KlevuFetch(search("hoodies"))
console.log(result.queriesById("search")?.records)Simple Playground
Click here to see a simple example you can play with.