npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trieve-search-component

v0.2.4

Published

The easiest way to get up and running in your app using trieve search.

Downloads

2,660

Readme

Trieve Search Component

The easiest way to get up and running in your app using trieve search.

How to use

Install using your favorite package manager:

yarn add trieve-search-component
# or
npm install trieve-search-component
# or
pnpm install trieve-search-component

After installing the first step is to instantiate a new TrieveSDK like so:

import { TrieveSDK } from "trieve-ts-sdk";

export const trieve = new TrieveSDK({
  apiKey: "<your-api-key>",
  datasetId: "<dataset-to-use>",
});

And then you can use any of the two components in your React application or as web component:

Search Modal

light closed dark closed light open

Usage in React:

<TrieveModalSearch trieve={trieve} />

Usage in Web Components:

initModalSearch({
  trieve: new TrieveSDK({
    // your options
  })
})


<trieve-modal-search />

If you are using it in JSX environment you will need to add the trieve-modal-search to the JSX attributes, for solid that would be:

declare module "solid-js" {
  namespace JSX {
    interface IntrinsicElements {
      "trieve-modal-search": {};
      "trieve-search": {};
    }
  }
}

Props

| Name | Type | Default | | -------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------ | | datasetId | string | '' | | apiKey | string | '' | | baseUrl | string | "https://api.trieve.ai" | | type | "docs" | "ecommerce" | "docs" | | useGroupSearch | boolean | false | | chat | boolean | true | | analytics | boolean | true | | placeholder | string | "Search..." | | onResultClick | () => void | () => {} | | theme | "light" or "dark" | "light" | | searchOptions | AutocompleteReqPayload | { search_type: "fulltext" } | | openKeyCombination | { key?: string; label?: string; ctrl?: boolean }[] | [{ ctrl: true }, { key: "k", label: "K" }] | | ButtonEl | JSX.ElementType | null | | suggestedQueries | boolean | true | | defaultSearchQueries | string[] | [] | | defaultAiQuestions | string[] | [] | | brandLogoImgSrcUrl | string | null | | brandName | string | null | | brand Color | string | #CB53EB | | problemLink | string (example: "mailto:[email protected]?subject=") | null | | responsive | boolean | false |

Search Results

light dark

Usage in React:

<TrieveSearch apiKey="<your trieve apiKey>" datasetId="<your trieve datasetId" />

Usage in Web Components:

<trieve-search apiKey="<your trieve apiKey>" datasetId="<your trieve datasetId" />

Usage with Vanilla JS

import "trieve-search-component/styles";
import { renderToDiv } from 'trieve-search-component/vanilla';

const root = document.getElementById('root');
renderToDiv(root, {
  apiKey: "<Your Trieve Api Key>"
  datasetId: "<Your Trieve Dataset Id>"
   // ... other props
})

Props

| Name | Type | Default | | ------------- | ---------------------------------------------------------------------------------------------- | --------------------------- | | datasetId | string | '' | | apiKey | string | '' | | placeholder | string | "Search..." | | onResultClick | () => void | () => {} | | theme | "light" or "dark" | "light" | | searchOptions | SearchChunksReqPayload | { search_type: "hybrid" } |

License

MIT

Development Guide

The example/ folder shows the example application for what rendering this would look like

Start the listener to update the search-component's css and javascript

$clients/search-component yarn
$clients/search-component yarn dev

Run the example application

$clients/search-component cd example/
$clients/search-component yarn
$clients/search-component yarn dev