JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q61793F
  • License MIT

React hooks for A/B testing with Testly

Package Exports

  • @testlyjs/react
  • @testlyjs/react/dist/index.esm.js
  • @testlyjs/react/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@testlyjs/react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@testlyjs/react

A infraestrutura de Testes A/B definitiva para o ecossistema React.

NPM Version React Support Bundle Size

O Testly transforma testes A/B em código.

Defina variantes diretamente no seu frontend e deixe que nossa infraestrutura cuide da distribuição estatística, persistência de usuários e coleta de métricas em tempo real.

📖 Documentação Oficial Completa →


🔥 Por que Testly?

  • ⚡ Performance Native: Otimizado para evitar o Flicker (pisca-pisca) de conteúdo.
  • ⚛️ Universal: Compatível com React 16.8+, 17, 18 e 19 (Next.js, Vite, Remix).
  • 🛡️ Type-Safe: Tipagem nativa para variantes e conversões.
  • 📦 Minimalista: Menos de 10KB, sem dependências externas.

🚀 Início Rápido em 2 Minutos

1. Instalação

npm install @testlyjs/react

2. Configuração do Provider

Envolva sua aplicação no nível mais alto:

import { TestlyProvider } from '@testlyjs/react';

function Root() {
  return (
    <TestlyProvider apiKey="sua_tk_live_aqui">
      <App />
    </TestlyProvider>
  );
}

3. Implementando um Experimento

O hook useExperiment faz a atribuição da variante e disponibiliza a função convert vinculada ao contexto do teste.

import { useExperiment } from '@testlyjs/react';

function Navbar() {
  const { variant, convert, loading } = useExperiment('navbar-cta-test');

  if (loading) return null;

  return (
    <button onClick={() => convert('button_click')}>
      {variant === 'variant-b' ? 'Começar Grátis' : 'Entrar'}
    </button>
  );
}

📘 Guia de Referência

Para manter seu projeto sempre atualizado, consulte nossa documentação centralizada:


🛡️ Resiliência e Segurança

  • Deduplicação Inteligente: Proteção contra disparos duplicados em React.StrictMode.
  • Failsafe: Se o servidor estiver offline, o SDK utiliza o fallback definido, garantindo que sua UI nunca quebre.
  • Privacy First: Sem cookies de terceiros, em total conformidade com LGPD/GDPR.

MIT © Testly