Widget de feedback para aplicações React
npm install @feedget/widget// App.tsx ou _app.tsx
import { FeedgetWidget } from "@feedget/widget/react";
import "@feedget/widget/styles.css";
function App() {
return (
<div>
<h1>Minha Aplicação</h1>
<FeedgetWidget apiKey="feedget_pk_live_abc123..." />
</div>
);
}App.tsxPara Next.js com App Router, adicione o widget no layout principal:
// app/layout.tsx
import { FeedgetWidget } from "@feedget/widget/react";
import "@feedget/widget/styles.css";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="pt-BR">
<body>
{children}
<FeedgetWidget
apiKey={process.env.NEXT_PUBLIC_FEEDGET_API_KEY || ""}
/>
</body>
</html>
);
}Para Next.js com Pages Router, adicione no _app.tsx:
// pages/_app.tsx
import type { AppProps } from "next/app";
import { FeedgetWidget } from "@feedget/widget/react";
import "@feedget/widget/styles.css";
export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Component {...pageProps} />
<FeedgetWidget
apiKey={process.env.NEXT_PUBLIC_FEEDGET_API_KEY || ""}
/>
</>
);
}| Propriedade | Tipo | Obrigatório | Descrição |
|---|---|---|---|
apiKey | string | Sim | Sua API key do Feedget (gerada no dashboard) |
orientation | "left" | "right" | Não | Posição do widget na tela (padrão: "right") |
Nota: A URL da API é configurada automaticamente pelo widget. Você só precisa fornecer a API Key gerada no dashboard.
# Feedget Configuration REACT_APP_FEEDGET_API_KEY=feedget_pk_live_abc123... # ou para Vite: VITE_FEEDGET_API_KEY=feedget_pk_live_abc123...
# Feedget Configuration NEXT_PUBLIC_FEEDGET_API_KEY=feedget_pk_live_abc123...
Importante: Adicione essas variáveis ao seu arquivo .env para manter suas credenciais seguras. A API key deve ser prefixada com NEXT_PUBLIC_ no Next.js para estar disponível no cliente.
Por padrão, o widget aparece no canto inferior direito. Você pode alterá-lo para o canto esquerdo usando a prop orientation:
// Widget no canto esquerdo <FeedgetWidget apiKey="feedget_pk_live_abc123..." orientation="left" /> // Widget no canto direito (padrão) <FeedgetWidget apiKey="feedget_pk_live_abc123..." orientation="right" />
// App.tsx
import React from "react";
import { FeedgetWidget } from "@feedget/widget/react";
import "@feedget/widget/styles.css";
import { MyComponent } from "./MyComponent";
function App() {
return (
<div className="app">
<header>
<h1>Minha Aplicação</h1>
</header>
<main>
<MyComponent />
</main>
<FeedgetWidget
apiKey={process.env.REACT_APP_FEEDGET_API_KEY || ""}
metadata={{
userId: "user-123",
environment: process.env.NODE_ENV
}}
/>
</div>
);
}
export default App;import "@feedget/widget/styles.css";feedget_pk_live_...)npm install @feedget/widget ou pnpm installnode_modules e package-lock.json, depois reinstale@feedget/widget/reactSe encontrar esse erro no Next.js, certifique-se de que o componente está sendo renderizado apenas no cliente:
// Adicione "use client" no topo do arquivo
"use client";
import { FeedgetWidget } from "@feedget/widget/react";