Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
---
category: Guides
title: How to Use openstatus React Widget
description: Add an openstatus status widget to your React or Next.js app with the @openstatus/react package as a React Server Component, or build your own with the typed fetch helper.
---
Install the [npm](https://www.npmjs.com/package/@openstatus/react) package:
```bash
npm install @openstatus/react
```
## React server component
```tsx
import { StatusWidget } from "@openstatus/react";
export function Page() {
return <StatusWidget slug="status" />;
}
```
It will automatically attach the slug to the href to allow the user to open a new tab on click to `https://slug.openstatus.dev`. If you want to redirect to a specific page, use the `href` property:
```tsx
<StatusWidget slug="documenso" href="https://status.documenso.com" />
```
<Aside>`StatusWidget` is an **async function** and will only work with RSC. Using it within a plain React app will not work.</Aside>
### Styling
#### With Tailwind CSS
The widget is styled with Tailwind utility classes, so Tailwind has to scan the published package
for them.
**Tailwind v4** — add a `@source` directive to the CSS file that imports Tailwind:
```css
/* app/globals.css */
@import "tailwindcss";
@source "../node_modules/@openstatus/react/dist";
```
**Tailwind v3** — add the package to `content`:
```js
// tailwind.config.js
module.exports = {
content: [
"./app/**/*.{tsx,ts,mdx,md}",
"./node_modules/@openstatus/react/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
};
```
#### Without Tailwind CSS
```tsx
// app/layout.tsx
import "@openstatus/react/dist/styles.css";
```
## Typed fetch function
```tsx
import { getStatus } from "@openstatus/react";
// React Server Component
async function CustomStatusWidget() {
const res = await getStatus("slug");
// ^StatusResponse = { status: Status }
const { status } = res;
// ^Status = "unknown" | "operational" | "degraded_performance" | "partial_outage" | "major_outage" | "under_maintenance" | "incident"
return <div>{/* customize */}</div>;
}
```
`getStatus` never throws: a network failure or a non-`2xx` response degrades to
`{ status: "unknown" }` rather than bubbling an error into your page.
### Pointing at a self-hosted API
Both `getStatus` and `StatusWidget` call `https://api.openstatus.dev` by default. If you self-host
openstatus, set `OPENSTATUS_API_URL` on the server — that is the only lever for `StatusWidget`,
which takes just `slug` and `href`. `getStatus` additionally accepts the base URL as a second
argument:
```tsx
const res = await getStatus("slug", "https://api.status.example.com");
```
The variable is read at request time and has no `NEXT_PUBLIC_` prefix, so a prebuilt image can be
pointed at a different API without rebuilding.