{"id":13760299,"url":"https://github.com/PEZ/shadow-w-backend","last_synced_at":"2025-05-10T10:32:08.449Z","repository":{"id":63484656,"uuid":"529294518","full_name":"PEZ/shadow-w-backend","owner":"PEZ","description":"A tiny example project for setting up development using nREPL and shadow-cljs.","archived":false,"fork":false,"pushed_at":"2022-08-29T11:30:38.000Z","size":10,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T19:43:16.508Z","etag":null,"topics":["clojure","clojurescript","nrepl","shadow-cljs"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"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/PEZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["PEZ"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-08-26T14:41:36.000Z","updated_at":"2025-02-23T08:57:27.000Z","dependencies_parsed_at":"2022-11-19T20:45:53.112Z","dependency_job_id":null,"html_url":"https://github.com/PEZ/shadow-w-backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PEZ%2Fshadow-w-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PEZ%2Fshadow-w-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PEZ%2Fshadow-w-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PEZ%2Fshadow-w-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PEZ","download_url":"https://codeload.github.com/PEZ/shadow-w-backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253401685,"owners_count":21902711,"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":["clojure","clojurescript","nrepl","shadow-cljs"],"created_at":"2024-08-03T13:01:07.361Z","updated_at":"2025-05-10T10:32:08.117Z","avatar_url":"https://github.com/PEZ.png","language":"Clojure","readme":"# nREPL – Starting shadow-cljs from lein or clojure\n\nThis is a tiny example project for setting up development using [nREPL](https://nrepl.org/) and [shadow-cljs](https://github.com/thheller/shadow-cljs). The [ClojureScript](https://clojurescript.org) app is rendered using [Reagent](https://reagent-project.github.io/).\n\nBy default the project uses [deps.edn](https://clojure.org/guides/deps_and_cli) for dependencies. There is a [Leiningen](https://leiningen.org/) setup as well.\n\n## Install npm dependencies\n\n```\nnpm i\n```\n\n(Or `yarn`, whatever you fancy.)\n\n## Using a Clojure editor\n\nIf you are using something like [Calva](https://calva.io/) or [CIDER](https://cider.mx/), just jack in to the project as a **shadow-cljs** project type, and hack away.\n\n\n## Starting the project w/o an editor\n\nThe following instructions are for working with the project without an editor. You probably wouldn't do that. The point is mostly to demystify what the editors are doing when starting and attaching to a shadow-cljs project. So, you could say it is for educational purposes. Since it's pretty quick, why not try it out?\n\nYou can start this project using either `shadow-cljs`, `clojure`, or `lein`. As you are doing this to maybe learn something, please consider trying all three options.\n\n### With the shadow-cljs npm executable\n\n```\nnpx shadow-cljs -d cider/cider-nrepl:0.28.5 clj-repl\n...\nshadow.user=\u003e\n```\n\nNB: If you use `shadow-cljs` it will in turn use `clojure` to start Clojure and the nREPL server. (Or `lein` if you edit `shadow-cljs.edn` and change this.)\n\n### With deps/`clojure`\n\nTo start the project and the nREPL server with `clojure`, in one terminal:\n\n```\n% clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,\"1.0.0\"},cider/cider-nrepl {:mvn/version,\"0.28.5\"}}}'  -m nrepl.cmdline --middleware \"[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]\"\n```\n\nAttach to the nREPL server in another terminal:\n\n```\n% clojure -Sdeps '{:deps {reply/reply {:mvn/version \"0.5.1\"}}}' -M -m reply.main --attach `\u003c .nrepl-port` \n...\nuser=\u003e \n```\n\nOr, since the `deps.edn` file specifies the `nrepl` dependency:\n\n```\n% clj -M -m nrepl.cmdline -c --port `\u003c .nrepl-port`\n...\nuser=\u003e \n```\n\n### With Leiningen\n\nTo start the project and the nREPL server with Leiningen, in one terminal:\n\n```\nlein update-in :dependencies conj '[nrepl,\"1.0.0\"]' -- update-in :dependencies conj '[cider/cider-nrepl,\"0.28.5\"]' -- update-in :plugins conj '[cider/cider-nrepl,\"0.28.5\"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headless\n```\n\n**NB: This doesn't properly inject the shadow-cljs nREPL middleware for some reason.** You'll need to add this to `project.clj`:\n\n```clojure\n  :repl-options {:nrepl-middleware [shadow.cljs.devtools.server.nrepl/middleware]}\n```\n\nAttach to the nREPL server in another terminal:\n\n```\n% lein repl :connect\n...\nmain.server=\u003e \n```\n\n## Starting shadow-cljs\n\n(Not needed if if you started the REPL using the shadow-cljs executable.)\n\n``` clojure\nuser=\u003e (do (require 'shadow.cljs.devtools.server) (shadow.cljs.devtools.server/start!))\nshadow-cljs - HTTP server available at http://localhost:8700\nshadow-cljs - server version: 2.19.9 running at http://localhost:9632\nshadow-cljs - nREPL server started on port 57770\n:shadow.cljs.devtools.server/started\nuser=\u003e \n```\n\n(Never mind the second nREPL server started here.)\n\nAt this point the shadow-cljs dev browser is running and serving on port 8700, but your ClojureScript app is not running. It is not even compiled. As you'll see if you visit http://localhost:8700 with your browser.\n\n## Start the shadow-cljs watcher\n\n(The `require` is not needed if you started the REPL with the shadow-cljs executable.)\n\n``` clojure\nuser=\u003e (do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/watch :app))\n[:app] Configuring build.\n[:app] Compiling ...\n[:app] Build completed. (170 files, 0 compiled, 0 warnings, 1.35s)\n:watching\nuser=\u003e \n```\n\n## Start the ClojureScript app\n\nOpen http://localhost:8700 in a web browser. (Or refresh if you opened it in an earlier step.)\n\nConfirm that the shadow-cljs watcher is running by editing some hiccup in `src/main/core.cljs` and save the file.\n\n## Attach to the ClojureScript REPL\n\n(The `require` is not needed if you started the REPL with the shadow-cljs executable.)\n\n``` clojure\nuser=\u003e (do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/nrepl-select :app))\nTo quit, type: :cljs/quit\n[:selected :app]\ncljs.user=\u003e\n```\n\n(If you instead of `[:selected :app]` see `:missing-nrepl-middleware`, you are probably using Leiningen and missed a note above.)\n\nConfirm that your REPL is attached to the app in the browser:\n\n```clojure\ncljs.user=\u003e (js/alert \"BOOM!\")\n```\n\n(You need to dismiss the alert in the browser to get the prompt back.)\n\nSomething more interesting could be to update the app state, maybe?\n\n```clojure\ncljs.user=\u003e (load-file \"src/main/core.cljs\")\n[]\ncljs.user=\u003e (in-ns 'main.core)\nnil\nmain.core=\u003e (swap! app-state update :text str \" UPDATED\")\n{:text \"Hello world! UPDATED\"}\n```\n\n(Check the app in the browser.)\n\n## Notes\n\nIf you use this project as a base for something, then edit `.gitignore` and remove `package-lock.json`.\n\nThe reason the Leiningen project file is not including the shadow nrepl middleware configuration is that I think [the failure to inject via the command line is a bug in Leiningen](https://codeberg.org/leiningen/leiningen/issues/10) and that it will eventually be fixed.","funding_links":["https://github.com/sponsors/PEZ"],"categories":["Clojure"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPEZ%2Fshadow-w-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPEZ%2Fshadow-w-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPEZ%2Fshadow-w-backend/lists"}