{"id":16014918,"url":"https://github.com/thheller/reagent-react-integration","last_synced_at":"2025-07-04T16:06:55.885Z","repository":{"id":140237280,"uuid":"166219143","full_name":"thheller/reagent-react-integration","owner":"thheller","description":null,"archived":false,"fork":false,"pushed_at":"2019-01-17T12:46:27.000Z","size":245,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T11:51:28.267Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thheller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-01-17T12:04:36.000Z","updated_at":"2019-08-16T21:16:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"d837cef4-50a0-40b6-8bf2-1bbd9a9b65df","html_url":"https://github.com/thheller/reagent-react-integration","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"e45bd1b139e762cf6576b078a87ce7cace93f725"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thheller/reagent-react-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Freagent-react-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Freagent-react-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Freagent-react-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Freagent-react-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thheller","download_url":"https://codeload.github.com/thheller/reagent-react-integration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Freagent-react-integration/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263573186,"owners_count":23482603,"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":[],"created_at":"2024-10-08T15:05:31.597Z","updated_at":"2025-07-04T16:06:55.853Z","avatar_url":"https://github.com/thheller.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Integrating Reagent into JavaScript/React\n\n_WARNING: This won't be easy, you are about to marry together two separate realms._\n\n### What is it trying to achieve?\n\nYou want to start gradually using ClojureScript/Reagent in an existing JavaScript/React project.\n\n### Problems\n\n1. How to export ClojureScript into JavaScript\n2. How to share common dependencies (React, etc.) between ClojureScript/Reagent and JavaScript/React code\n3. How to enable hot-reloading for ClojureScript code\n\n### Solving step by step\n\n#### How to export ClojureScript into JavaScript\n\n1. Bootstrap ClojureScript project and write your Reagent component\n2. [Use `reagent.core/reactify-component` to adapt Reagent component for usage with JS/React](https://github.com/roman01la/reagent-react-integration/blob/master/cljs-src/app/core.cljs#L18)\n3. [Use `^:export` meta on component's function to export it into a global scope (`window` object)](https://github.com/roman01la/reagent-react-integration/blob/master/cljs-src/app/core.cljs#L17)\n4. [Put `\u003cscript\u003e` tag referring ClojureScript output bundle into your HTML before JS project's script](https://github.com/roman01la/reagent-react-integration/blob/master/public/index.html#L12)\n5. [Use Reagent components in your JS project](https://github.com/roman01la/reagent-react-integration/blob/master/src/index.js#L5)\n\n#### How to share common dependencies\n\n##### In JavaScript project\n\n1. In your JS project [create a module that imports shared dependencies and exports them into global scope (`window` object)](https://github.com/roman01la/reagent-react-integration/blob/master/src/deps.js)\n2. Configure two builds (here using Webpack)\n   - With an [entry point with shared dependencies](https://github.com/roman01la/reagent-react-integration/blob/master/webpack.config.js#L4-L10)\n   - With application entry point and [shared dependencies configured as externals](https://github.com/roman01la/reagent-react-integration/blob/master/webpack.config.js#L20-L23)\n3. [Put `\u003cscript\u003e` tag referring shared deps bundle into your HTML before ClojureScript project's script](https://github.com/roman01la/reagent-react-integration/blob/master/public/index.html#L11)\n\n##### In ClojureScript project\n\n1. [Exclude `cljsjs/react` and `cljsjs/react-dom` transitive dependencies from `reagent` dependency](https://github.com/roman01la/reagent-react-integration/blob/master/deps.edn#L4)\n2. [Using `:foreign-libs` option alias `react` and `react-dom` with globally exported (from JS project) ones](https://github.com/roman01la/reagent-react-integration/blob/master/dev.cljs.edn#L9-L12)\n   - `:file` is a required field in `:foreign-libs`, [provide a path](https://github.com/roman01la/reagent-react-integration/blob/master/dev.cljs.edn#L12) to an [empty stub file](https://github.com/roman01la/reagent-react-integration/blob/master/stub.js)\n3. [Set `:infer-externs` to `true` so that compiler can infer external references to shared deps](https://github.com/roman01la/reagent-react-integration/blob/master/dev.cljs.edn#L6)\n\n#### How to enable hot-reloading for ClojureScript code\n\nOn every change to ClojureScript source Figwheel will apply a patch to the code running in the browser. In order to reflect those changes on the screen you have to re-render the app so the new code will be executed.\n\n##### In JavaScript project\n\n- [Export rendering function into global scope (`window` object)](https://github.com/roman01la/reagent-react-integration/blob/master/src/index.js#L46)\n\n##### In ClojureScript project\n\n- Use [`^:figwheel-hooks` meta](https://github.com/roman01la/reagent-react-integration/blob/master/cljs-src/app/core.cljs#L1) to enable Figwheel hooks and [`^:after-load` meta on a function that calls rendering function exported from JS](https://github.com/roman01la/reagent-react-integration/blob/master/cljs-src/app/core.cljs#L38-L39)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthheller%2Freagent-react-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthheller%2Freagent-react-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthheller%2Freagent-react-integration/lists"}