Back to directory
whitphx avatar

streamlit-component-template-react-hooks

Streamlit component lib with React hooks and template project using it. Read more below about its uses, features, and usage.

Clone repository

git clone https://github.com/whitphx/streamlit-component-template-react-hooks.git

77

Stars

15

Forks

1

Watchers

MIT

License

streamlit-component-template-react-hooks

Test streamlit-component-lib-react-hooks

version license

ko-fi

Buy Me A Coffee

GitHub Sponsors

This repo contains below.

  • A template for creating Streamlit Components with React Hooks and functional component style: ./template.
    • This was originally based on the official React template but has been modified to use the functional component style with hooks and modern JavaScript stack such as Vite instead of deprecated Create React App.
  • The source code of streamlit-component-lib-react-hooks npm package, which provides React-Hooks style API for Streamlit Component: ./streamlit-component-lib-react-hooks.
    • This is only for development purpose and the users of ./template do not have to see it.

Quickstart for the component template

  • Ensure you have Python 3.9+ and Node.js installed.
  • Clone this repo.
  • Create a new Python virtual environment for the template:
$ cd template
$ python3 -m venv venv  # create venv
$ . venv/bin/activate   # activate venv
$ pip install streamlit # install streamlit
  • Initialize and run the component template frontend:
$ cd template/my_component/frontend
$ npm install
$ npm run dev
  • From a separate terminal, run the template's Streamlit app:
$ cd template
$ . venv/bin/activate  # activate the venv you created earlier
$ streamlit run my_component/__init__.py  # run the example
  • If all goes well, you should see something like this: Quickstart Success
  • Modify the frontend code at my_component/frontend/src/MyComponent.tsx.
  • Modify the Python code at my_component/__init__.py.

Releases

May 22, 2025

Download .zip

What's Changed

Fix typos and missing dependence by @F-loat in #157

New Contributors

@F-loat made their first contribution in #157

Full Changelog: v2.1.0...v2.1.1

Mar 13, 2025

Download .zip

What's Changed

Fix template to use React 18 properly by @whitphx in #130 Dev/react19 by @whitphx in #131

Full Changelog: v2.0.10...v2.1.0

Mar 13, 2025

Download .zip

What's Changed

Bump softprops/action-gh-release from 1 to 2 by @dependabot in #119 Delete unused dependencies by @whitphx in #125

Full Changelog: v2.0.0...v2.0.1

Mar 12, 2025

Download .zip

What's Changed

Update React to v18 and Replace CRA with Vite by @whitphx in #116 Dev/admin tools update by @whitphx in #117

Full Changelog: v1.2.8...v2.0.0