A modern search bar application built with React Native (Expo) and Typesense, featuring instant search capabilities for mobile devices.
- React Native (Expo)
- Typesense
- react-instantsearch-core
- typesense-instantsearch-adapter
- TypeScript
- Node.js 18+ and npm 9+.
- Docker (for running Typesense locally). Alternatively, you can use a Typesense Cloud cluster.
- Expo Go app on your mobile device or an iOS/Android simulator.
- Basic knowledge of React Native.
git clone https://github.com/typesense/code-samples.git
cd typesense-react-native-search-barnpm installCreate a .env file in the project root with the following content:
EXPO_PUBLIC_TYPESENSE_API_KEY=xyz
EXPO_PUBLIC_TYPESENSE_HOST=10.0.2.2
EXPO_PUBLIC_TYPESENSE_PORT=8108
EXPO_PUBLIC_TYPESENSE_PROTOCOL=httpNote:
- For Android emulator, use
10.0.2.2as the host (this maps tolocalhoston your machine). - For iOS simulator, use
localhostas the host. - For physical devices, use your machine's local IP address (e.g.,
192.168.1.100) or use Typesense Cloud cluster.
├── components
│ ├── BookCard.tsx
│ ├── BookList.tsx
│ ├── Heading.tsx
│ └── SearchInput.tsx
├── types
│ └── Book.ts
├── utils
│ └── typesense.ts
├── App.tsx
├── app.json
└── package.json
npx expo startThis will start the Expo development server. You can then:
- Scan the QR code with Expo Go app (Android) or Camera app (iOS).
- Press
ato open in Android emulator. - Press
ito open in iOS simulator.
For production deployment, we don't recommend storing sensitive information in the environment variables. Instead, use a backend service to handle the API requests with some form of authentication.