@replit/extensions-react
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

Replit Extensions API Client (React)

The React Extensions API Client comes with a set of hooks and components that combine to make a blazingly fast and seamless developer experience.

Installation

npm install @replit/extensions-react
yarn add @replit/extensions-react
pnpm add @replit/extensions-react

Usage

Fork the React Extension Template to get started. Alternatively, you can start from scratch by wrapping your application with the HandshakeProvider component imported from @replit/extensions-react.

import { HandshakeProvider } from "@replit/extensions-react";
import { createRoot } from "react-dom/client";
import App from "./App";

createRoot(document.getElementById("root")).render(
  <HandshakeProvider>
    <App />
  </HandshakeProvider>
);

In the App function, check the handshake status with the useReplit hook.

import { useReplit } from "@replit/extensions-react";

function App() {
  const { status, error, replit } = useReplit();

  if (status === "loading") {
    return <div>Loading...</div>;
  }

  if (status === "error") {
    return <div>An error occurred: {error?.message}</div>;
  }

  return <div>Extension is Ready!</div>;
}

Help

If you don't understand something in the documentation, have found a bug, or would like to request a feature, you can get help on the Ask Forum.

Package Sidebar

Install

npm i @replit/extensions-react

Weekly Downloads

4

Version

0.6.0

License

MIT

Unpacked Size

1.16 MB

Total Files

10

Last publish

Collaborators

  • sareini
  • krishatreplit
  • mikewesthad
  • motzyball
  • replitdstewart
  • ryanweingast
  • theflowingsky
  • jonesit-replit
  • szymon_k
  • cdmistman
  • jackyzha0
  • jamesaustinreplit
  • lopezhoracio
  • bradymaddenreplit
  • ryantm
  • alexisreplit
  • ink404
  • brianpool
  • tobyho
  • brenoafb
  • masad-frost
  • lincolnreplit
  • stkenned
  • replitmatt
  • cbrewster
  • ltazmin_replit
  • moudy
  • lhchavez