While using the user search functionality, an empty array is displayed

I am developing a Next.js authentication application and encountering an issue where the user search functionality returns an empty array. I have verified in the Amity console that the user does exist. However, despite this, I’m consistently receiving an empty array.

Below is the code from the file where I’m attempting to implement the user search functionality:

import { getDataFromToken } from “@/helpers/getDataFromToken”;
import { NextRequest, NextResponse } from “next/server”;
import User from “@/models/userModel”;
import connect from “@/dbconfig/dbConfig”;
import { Client, API_REGIONS } from ‘@amityco/ts-sdk’;
import { UserRepository } from ‘@amityco/ts-sdk’;

const client = Client.createClient(${process.env.AMITY_API_KEY}, API_REGIONS.US);

const sessionHandler: Amity.SessionHandler = {
sessionWillRenewAccessToken(renewal) {

const handleConnect = async (userId: string, displayName: string) => {
console.log(userId, displayName)
await Client.login({ userId, displayName }, sessionHandler);


export async function GET(request: NextRequest) {

try {
    const userId = await getDataFromToken(request);
    const user = await User.findOne({ _id: userId }).select("-password");
    handleConnect(`${user.email}`, `${user.username}`);

    const unsub = UserRepository.searchUserByDisplayName({ displayName: `${user.username}` }, ({ data: user }) =>

    return NextResponse.json({
        mesaaage: "User found",
        data: user
} catch (error: any) {
    return NextResponse.json({ error: error.message }, { status: 400 });

ts-sdk version

: 6.10.0
The amity console user management tab screenshot is also attached

Hello, let we pass to our team to help check, thank you.

Hello, may I confirm how many letters you entered for your search? Was it fewer than three characters?

there were 3 or more 3 letters in display name

Thank you for confirming. So, when you performed the search for example for this display name :

  • jethaniya_20 - did you search for jeth or jethaniya_2, is that correct? Not je?