{"id":15663589,"url":"https://github.com/cmorten/deno-react-base-server","last_synced_at":"2025-09-12T00:16:55.084Z","repository":{"id":102855336,"uuid":"264191193","full_name":"cmorten/deno-react-base-server","owner":"cmorten","description":"Minimal React SSR Base Server in Deno.","archived":false,"fork":false,"pushed_at":"2024-01-28T09:47:20.000Z","size":32,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T01:31:41.458Z","etag":null,"topics":["deno","deno-module","deno-react-base-server","denoland","poc","react"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/cmorten.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["cmorten"]}},"created_at":"2020-05-15T12:44:42.000Z","updated_at":"2025-02-09T23:55:10.000Z","dependencies_parsed_at":"2024-10-23T08:37:20.573Z","dependency_job_id":null,"html_url":"https://github.com/cmorten/deno-react-base-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmorten%2Fdeno-react-base-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmorten%2Fdeno-react-base-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmorten%2Fdeno-react-base-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmorten%2Fdeno-react-base-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmorten","download_url":"https://codeload.github.com/cmorten/deno-react-base-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252712611,"owners_count":21792344,"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":["deno","deno-module","deno-react-base-server","denoland","poc","react"],"created_at":"2024-10-03T13:38:31.916Z","updated_at":"2025-05-06T15:28:53.816Z","avatar_url":"https://github.com/cmorten.png","language":"TypeScript","funding_links":["https://github.com/sponsors/cmorten"],"categories":["TypeScript"],"sub_categories":[],"readme":"# deno-react-base-server\n\nMinimal React SSR Base Server in Deno.\n\n\u003e As featured in [Open JS World 2020](https://www.youtube.com/watch?v=doug6st5vAs).\n\nPlease use this as an a small demo of how you _could_ write a React SSR application in Deno, and as a useful utility for quickly rendering any React component with SSR. For a walk-through check out [this article](https://dev.to/craigmorten/writing-a-react-ssr-app-in-deno-2m7).\n\nThis server uses the [Opine](https://github.com/asos-craigmorten/opine) web framework for Deno.\n\n**Recommendation**: For a more complex / better React SSR example using bundling, check out the [React example](https://github.com/asos-craigmorten/opine/tree/main/examples/react) on the Opine project.\n\n## Usage\n\n### Using the module\n\nYou can use `deno-react-base-server` as an imported module through the [mod.ts](./mod.ts) module.\n\nWrite your React application and export the top level component as the _default export_:\n\n```tsx\nimport React from \"https://dev.jspm.io/react@16.13.1\";\n\ndeclare global {\n  namespace JSX {\n    interface IntrinsicElements {\n      button: any;\n      div: any;\n      h1: any;\n      p: any;\n    }\n  }\n}\n\nconst App = () =\u003e {\n  const [count, setCount] = React.useState(0);\n\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eHello DenoLand!\u003c/h1\u003e\n      \u003cbutton onClick={() =\u003e setCount(count + 1)}\u003eClick the 🦕\u003c/button\u003e\n      \u003cp\u003eYou clicked the 🦕 {count} times\u003c/p\u003e\n    \u003c/div\u003e\n  );\n};\n\n/**\n * Export the component as the _default export_.\n */\nexport default App;\n```\n\nThen create an entrypoint script to run your React application on a specified port:\n\n```tsx\n// Import deno-react-base-server\nimport baseServer from \"https://raw.githubusercontent.com/asos-craigmorten/deno-react-base-server/main/mod.tsx\";\n\n// Update `appModulePath` from the example React component to your own.\nbaseServer({\n  appModulePath:\n    \"https://raw.githubusercontent.com/asos-craigmorten/deno-react-base-server/main/example/app.tsx\",\n  port: 3000,\n});\n```\n\nWhere `appModulePath` is the path to your app component module. This can be any path that Deno's import supports, i.e. relative / absolute file path, URL etc.\n\nThen you can run your application using the Deno `run` command and passing the path to your entrypoint script. For example:\n\n```console\ndeno run --allow-net --allow-read \"https://raw.githubusercontent.com/asos-craigmorten/deno-react-base-server/main/example/entrypoint.ts\"\n```\n\n### Using the CLI\n\nYou can also use the [cli.ts](./cli.ts) module to run your React application direct from the command line.\n\nFor example, to start the example application in this repo on port 3000 we run the [cli.ts](./cli.ts) module and pass the port and path to our top-level React component module as flags.\n\n```console\ndeno run --allow-net --allow-read \"https://raw.githubusercontent.com/asos-craigmorten/deno-react-base-server/main/cli.ts\" --port 3000 --path \"https://raw.githubusercontent.com/asos-craigmorten/deno-react-base-server/main/example/app.tsx\"\n```\n\n**Note:** As with the [module](#using-the-module) usage, the top-level React component module provided to the `--path` flag must be exported as the _default export_.\n\n## Supported Deno Versions\n\nThis project has been tested with the following versions:\n\n- 1.2.2\n\nOnce Deno is installed, you can easily switch between Deno versions using the `upgrade` command:\n\n```bash\n# Upgrade to latest version:\ndeno upgrade\n\n# Upgrade to a specific version, replace `\u003cversion\u003e` with the version you want (e.g. `1.0.0`):\ndeno upgrade --version \u003cversion\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmorten%2Fdeno-react-base-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmorten%2Fdeno-react-base-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmorten%2Fdeno-react-base-server/lists"}