Installation & Integration

This document describes how to integrate the AI Powered Search package into Next.js projects for all brands. It is prepared to enable technical teams to perform a fast and standardized integration.


1. Package Installation

yarn add git+https://bitbucket.org/akinonteam/samanlik-client-js.git

2. Environment Variables

Required

SAMANLIK_API_URL=https://<ai-powered-search-api-url>

Optional

The following variables are optional. Default values are used if not defined.

Variable
Default

SAMANLIK_FALLBACK_PATH

/list/

SAMANLIK_PREFIX_PATH

(empty)

SAMANLIK_LANGUAGE

tr

SAMANLIK_TIMEOUT

5000


3. Creating the Server Action

Create the file src/views/header/samanlik-client.tsx:


4. Search Component Integration

Import

Usage

  • The AI Powered Search API call must be added to the handleSearchQuery function.

  • On a successful response, redirect using router.push(data.url_path).

  • On error, the user is redirected to the list page as a fallback.


5. File Structure


6. Testing

  1. Start the project with yarn dev.

  2. Enter test queries into the search box (e.g. polo, tişört, ayakkabı).

  3. Verify that the redirect works correctly.

  4. Test the fallback redirect in case of an API error.

Last updated

Was this helpful?