{"id":18243827,"url":"https://github.com/puntorigen/nicegui-react","last_synced_at":"2025-04-11T15:52:04.579Z","repository":{"id":261160100,"uuid":"883143376","full_name":"puntorigen/nicegui-react","owner":"puntorigen","description":"Integrate React components into your NiceGUI applications seamlessly.","archived":false,"fork":false,"pushed_at":"2024-11-06T16:13:32.000Z","size":19,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T11:50:15.255Z","etag":null,"topics":["nicegui","python","reactjs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/puntorigen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-04T13:02:18.000Z","updated_at":"2025-03-07T19:42:19.000Z","dependencies_parsed_at":"2024-11-05T02:37:29.480Z","dependency_job_id":null,"html_url":"https://github.com/puntorigen/nicegui-react","commit_stats":null,"previous_names":["puntorigen/nicegui-react"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fnicegui-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fnicegui-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fnicegui-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fnicegui-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puntorigen","download_url":"https://codeload.github.com/puntorigen/nicegui-react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248435182,"owners_count":21102986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nicegui","python","reactjs"],"created_at":"2024-11-05T09:03:29.244Z","updated_at":"2025-04-11T15:52:04.555Z","avatar_url":"https://github.com/puntorigen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NiceGUI React Integration\n\nIntegrate React components into your NiceGUI applications.\n\n## Introduction\n\nI created this package to seamlessly embed React components within NiceGUI projects. It handles bundling your React code using Vite, serves the compiled assets, and provides a way to pass props from Python to React and handle events from React in Python.\n\n## Features\n\n- **Easy Integration**: Embed React components directly into NiceGUI applications.\n- **Props and Events**: Pass props and handle events between Python and React.\n- **Automatic Bundling**: Automatically bundles your React code using Vite.\n- **Caching**: Efficiently caches builds to improve performance during development.\n\n## Installation\n\nInstall the package via pip:\n\n```bash\npip install nicegui-react\n```\n\n\n## Requirements\n- Python 3.6 or higher\n- NiceGUI installed\n- Node.js and npm installed (for building the React project)\n\n## Usage\nHere's how to use the React class in your NiceGUI application:\n\n```python\nfrom nicegui import ui\nfrom nicegui_react import React\n\n@ui.page(\"/\")\nasync def index():\n    with ui.card():\n        ui.label('Here is the React component:')\n        ui.button('Click me', on_click=lambda: react.props(title=\"Updated Title\"))\n\n        with ui.card_section():\n            react = React(\n                react_project_path=\"./path_to_your_react_project\",\n                main_component=\"App\"  # Replace with your main component's name\n            ).style('width: 100%; height: 100%;').props(\n                title=\"Hello from Python!\"\n            ).on('onClick', lambda event: ui.notify(f'Clicked on React component: {event}'))\n```\n\n\n\n## Parameters\n- *react_project_path* (str): Path to your React project directory.\n- *main_component* (str): Name of the main React component to render.\n- *component_id* (str, optional): Unique identifier for the component instance.\n- *env* (dict, optional): Environment variables to pass to the React app.\n- *use_legacy_peer_deps* (bool, optional): Whether to use legacy peer dependencies during npm install.\n- *dev* (bool, optional): If set to True, enables development mode.\n\n## Methods\n- props(**kwargs): Update the props passed to the React component.\n- on(event_name, handler): Register an event handler for events emitted from React.\n\n## Setting Up Your React Project\n- Place your React project in a directory relative to your Python script.\n- Ensure your package.json includes the necessary dependencies and scripts. The React class will help set this up if it's missing.\n- Your main component should be properly exported.\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Contributing\nIf you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.\n\n## Contact\nFeel free to reach out if you have any questions or suggestions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuntorigen%2Fnicegui-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuntorigen%2Fnicegui-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuntorigen%2Fnicegui-react/lists"}