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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fluent-translation-api

v1.0.0

Published

JavaScript/TypeScript client for FluentAPI instant translation service

Readme

@fluent-api/client

Official JavaScript/TypeScript client for FluentAPI - Instant translation service for messaging apps.

🚀 Installation

npm install @fluent-api/client
# or
yarn add @fluent-api/client

📖 Quick Start

import FluentClient from '@fluent-api/client';

// Initialize client
const fluent = new FluentClient({
  apiKey: 'your-api-key',
  serverUrl: 'https://fluent-api-sigma.vercel.app', // or your server
  userLanguage: 'en' // User's preferred language
});

// Connect
await fluent.connect('user-123');

// Send message (auto-translates for recipients)
await fluent.sendMessage({
  to: 'recipient-456',
  text: 'Hello World!'
});

// Receive translated messages
fluent.onMessage((message) => {
  console.log(message.translatedText); // Already in user's language!
});

🌍 Features

  • Instant translation between 100+ languages
  • WebSocket real-time messaging
  • Auto-reconnection on disconnect
  • Typing indicators support
  • Presence management (online/offline)
  • <50ms latency with caching

📡 API Reference

Initialize Client

const fluent = new FluentClient({
  apiKey: string,           // Required: Your API key
  serverUrl?: string,       // Optional: Default 'ws://localhost:3000'
  userLanguage: string,     // Required: User's language (e.g., 'en', 'ko', 'zh')
  fallbackLanguage?: string,// Optional: Default 'en'
  enableAutoDetect?: boolean,// Optional: Default true
  debug?: boolean          // Optional: Default false
});

Connect

await fluent.connect(userId: string);

Send Message

await fluent.sendMessage({
  to: string,               // Recipient user ID
  text: string,             // Message text
  language?: string,        // Optional: Override language
  conversationId?: string   // Optional: Group messages
});

Message Handlers

// Receive messages
fluent.onMessage((message) => {
  console.log(message.translatedText); // Translated to user's language
  console.log(message.originalText);   // Original text
  console.log(message.from);          // Sender ID
});

// Typing indicators
fluent.onTyping((typing) => {
  console.log(`${typing.from} is ${typing.isTyping ? 'typing' : 'not typing'}`);
});

// Presence updates
fluent.onPresence((presence) => {
  console.log(`${presence.userId} is ${presence.status}`);
});

🔧 Advanced Usage

Set Typing Status

await fluent.setTyping('recipient-id', true); // Start typing
await fluent.setTyping('recipient-id', false); // Stop typing

Update Language Preferences

await fluent.updateLanguagePreferences({
  primaryLanguage: 'es',
  fallbackLanguage: 'en',
  enableAutoDetect: true
});

Check Connection Status

if (fluent.isConnected) {
  console.log('Connected to FluentAPI');
}

🏗️ Framework Examples

React

import { useEffect, useState } from 'react';
import FluentClient from '@fluent-api/client';

function Chat() {
  const [fluent] = useState(() => new FluentClient({
    apiKey: 'your-key',
    userLanguage: navigator.language
  }));
  
  const [messages, setMessages] = useState([]);

  useEffect(() => {
    fluent.connect('user-123');
    
    fluent.onMessage((msg) => {
      setMessages(prev => [...prev, msg]);
    });

    return () => fluent.disconnect();
  }, []);

  return (
    <div>
      {messages.map(msg => (
        <div key={msg.id}>{msg.translatedText}</div>
      ))}
    </div>
  );
}

Vue.js

<template>
  <div v-for="msg in messages" :key="msg.id">
    {{ msg.translatedText }}
  </div>
</template>

<script>
import FluentClient from '@fluent-api/client';

export default {
  data() {
    return {
      fluent: null,
      messages: []
    };
  },
  mounted() {
    this.fluent = new FluentClient({
      apiKey: 'your-key',
      userLanguage: 'en'
    });
    
    this.fluent.connect('user-123');
    this.fluent.onMessage(msg => {
      this.messages.push(msg);
    });
  }
};
</script>

🌐 Supported Languages

All Google Translate languages including:

  • English, Spanish, French, German, Italian, Portuguese
  • Chinese, Japanese, Korean, Thai, Vietnamese
  • Arabic, Hebrew, Hindi, Russian, Turkish
  • And 100+ more languages

📄 License

MIT

🤝 Contributing

Visit GitHub

🚀 Live Demo

Try it at: https://fluent-api-sigma.vercel.app/