# react-native-katex

> WebView bundled KaTeX

Latest version **1.3.0** (published 2025-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-katex
pnpm add react-native-katex
yarn add react-native-katex
bun add react-native-katex
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2025-01-31 |
| First published | 2018-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Ivan Zakharchanka |
| Maintainers | 3axap4ehko |

## Links

- npm: https://www.npmjs.com/package/react-native-katex
- Repository: https://github.com/3axap4eHko/react-native-katex
- Homepage: https://github.com/3axap4eHko/react-native-katex#readme
- Issues: https://github.com/3axap4eHko/react-native-katex/issues
- npm.io page: https://npm.io/package/react-native-katex

## Dependencies (1)

- [react-native-webview](https://npm.io/package/react-native-webview.md) ^13.12.5

## Recent versions

- 1.3.0 (latest) — 2025-01-31
- 1.2.1 — 2025-01-31
- 1.2.0 — 2025-01-31
- 1.0.2 — 2024-09-18
- 1.0.1 — 2024-03-08
- 0.6.0 — 2024-03-08
- 0.5.1 — 2022-05-07
- 0.5.0 — 2022-05-07
- 0.4.3 — 2020-04-25
- 0.4.2 — 2020-03-26
- 0.4.1 — 2020-03-26
- 0.4.0 — 2020-03-26
- 0.3.0 — 2018-06-19
- 0.2.2 — 2018-01-10
- 0.2.1 — 2018-01-10
- … 2 more at https://npm.io/package/react-native-katex/versions

## README

# React Native [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)

React Native library that uses [WebView](https://github.com/react-native-community/react-native-webview) to render [KaTeX](https://github.com/Khan/KaTeX) mathematical expressions.
This approach enables the display of complex math formulas directly within React Native applications, facilitating their use in educational, scientific, and any other context where mathematical notation is required.

[![NPM version][npm-image]][npm-url]
[![Downloads][downloads-image]][npm-url]
[![Github CI Status][github-image]][github-url]

## Example

[EXPO Snack][expo-url]

<p align="center">
  <img src="screenshot.jpg" width="380" alt="React Native KaTeX">
</p>

## Usage
```javascript
const styles = StyleSheet.create({
  katex: {
    flex: 1,
  }
});

const inlineStyle = `
html, body {
  display: flex;
  background-color: #fafafa;
  justify-content: center;
  align-items: center;
  height: 100%;
  margin: 0;
  padding: 0;
}
.katex {
  font-size: 4em;
  margin: 0;
  display: flex;
}
`;

export default function App() {
  const inlineText = 'inline text';
  const [loaded, setLoaded] = useState(false);
  const [expression, setExpression] = useState(`\\text{${inlineText} }c=\\pm\\sqrt{a^2 + b^2}`);
  setTimeout(() => setExpression(`\\text{${inlineText} }d=\\pm\\sqrt{a^2 + b^2}\\text{ still}`), 2000);

  return (
    <Katex
      expression={expression}
      style={styles.katex}
      inlineStyle={inlineStyle}
      displayMode={false}
      throwOnError={false}
      errorColor="#f00"
      macros={{}}
      colorIsTextColor={false}
      onLoad={() => setLoaded(true)}
      onError={() => console.error('Error')}
    />
  );
}
```


## License
License [The MIT License](http://opensource.org/licenses/MIT)
Copyright (c) 2017-2024 Ivan Zakharchanka

[downloads-image]: https://img.shields.io/npm/dm/react-native-katex.svg
[npm-url]: https://www.npmjs.com/package/react-native-katex
[npm-image]: https://img.shields.io/npm/v/react-native-katex.svg

[github-url]: https://github.com/3axap4eHko/react-native-katex/actions/workflows/build.yml
[github-image]: https://github.com/3axap4eHko/react-native-katex/actions/workflows/build.yml/badge.svg

[expo-image]: https://raw.githubusercontent.com/3axap4eHko/react-native-katex/master/screenshot.png
[expo-url]: https://snack.expo.io/@3axap4ehko/react-native-katex

---
_Source: https://npm.io/package/react-native-katex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
