A modern search bar application built with Vite and Typesense, featuring instant search capabilities using vanilla JavaScript.
- Vite
- Vanilla JavaScript
- Typesense
- typesense-instantsearch-adapter & instantsearch.js
- Node.js 18+ and npm 9+.
- Docker (for running Typesense locally). Alternatively, you can use a Typesense Cloud cluster.
- Basic knowledge of JavaScript.
git clone https://github.com/typesense/code-samples.git
cd typesense-vanilla-js-searchnpm installCreate a .env file in the project root with the following content:
VITE_TYPESENSE_API_KEY=xyz
VITE_TYPESENSE_HOST=localhost
VITE_TYPESENSE_PORT=8108
VITE_TYPESENSE_PROTOCOL=http├── src
│ ├── main.js
│ ├── style.css
│ └── typesense.js
├── index.html
└── public
└── vite.svg
npm run devOpen http://localhost:5173 in your browser.
Set env variables to point the app to the Typesense Cluster:
VITE_TYPESENSE_API_KEY=xxx
VITE_TYPESENSE_HOST=xxx.typesense.net
VITE_TYPESENSE_PORT=443
VITE_TYPESENSE_PROTOCOL=https