Skip to content

elilambnz/react-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 19, 2023
48d6702 · Apr 19, 2023
Apr 2, 2023
Apr 1, 2023
Apr 19, 2023
Dec 8, 2022
Dec 8, 2022
Aug 1, 2022
Dec 31, 2022
Jan 29, 2023
Apr 19, 2023
Aug 1, 2022
Jan 21, 2023
Apr 19, 2023
Apr 19, 2023
Jan 6, 2023

Repository files navigation

react-py react-py

Effortlessly run Python code in your React apps. Try it out!

CI CodeQL MIT License NPM Version NPM Bundle Size


Quickstart

Install react-py with:

npm install react-py

Then, wrap your app in a PythonProvider component.

import { PythonProvider } from 'react-py'

function App() {
  return (
    // Add the provider to your app
    <PythonProvider>
      <Codeblock />
    </PythonProvider>
  )
}

render(<App />, document.getElementById('root'))

Using the usePython hook, you can run code and access both stdout and stderr. For full usage instructions, see the usage docs.

Documentation

For full documentation, visit elilambnz.github.io/react-py.

Examples

Basic Example

REPL

Interrupting Execution

Using Packages

File System

Custom Modules

Making API Calls

User Input

Matplotlib

Limitations

Most of the Python standard library is functional, except from some modules. The following modules can be imported, but are not functional due to the limitations of the WebAssembly VM:

  • multiprocessing
  • threading
  • sockets

Learn more about the limitations here.

License

react-py is available under the MIT License.

Contact

Eli Lamb - elilambnz
James Ansley - James-Ansley

Acknowledgments

This project is heavily based on Pyodide, a Python distribution for the browser and Node.js based on WebAssembly.

Contributing

If you're interested in contributing, please read our contributing docs before submitting a pull request.