{"id":15603458,"url":"https://github.com/codemeasandwich/load-jsx","last_synced_at":"2025-03-29T13:25:33.420Z","repository":{"id":71445843,"uuid":"464004336","full_name":"codemeasandwich/load-jsx","owner":"codemeasandwich","description":"A basic real-time transform pipeline for JSX -\u003e JavaScript in NodeJs","archived":false,"fork":false,"pushed_at":"2022-03-01T13:26:13.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-04T14:23:31.161Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/codemeasandwich.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":"2022-02-27T00:58:11.000Z","updated_at":"2022-03-01T13:13:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbc9afe9-a562-4325-822e-21a22fe8a35d","html_url":"https://github.com/codemeasandwich/load-jsx","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"3ecc7adc90146f88b4e55d6f3681d044aa7072c3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fload-jsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fload-jsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fload-jsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fload-jsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemeasandwich","download_url":"https://codeload.github.com/codemeasandwich/load-jsx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246188962,"owners_count":20737784,"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-03T03:03:26.386Z","updated_at":"2025-03-29T13:25:33.401Z","avatar_url":"https://github.com/codemeasandwich.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/codemeasandwich"],"categories":[],"sub_categories":[],"readme":"# load-jsx\n## A real-time transform for JSX ➜ JavaScript in ***NodeJs***\n\n[![npm version](https://badge.fury.io/js/load-jsx.svg)](https://www.npmjs.com/package/load-jsx) [![npm downloads](https://img.shields.io/npm/dt/load-jsx.svg)](http://www.npmtrends.com/load-jsx) [![Known Vulnerabilities](https://snyk.io/test/npm/redux-auto/badge.svg)](https://snyk.io/test/npm/load-jsx)  [![Buy me a coffee](https://img.shields.io/badge/buy%20me-a%20coffee-orange.svg)](https://www.buymeacoffee.com/codemeasandwich)\n\n---\n\n### The Problem:\n#### Setup Server-side Rendering\nSetting up **webpack** and **babel** for a **node project** can be complicated, when maybe all you want is to **render some react elements**.\n\n### **The Solution**:\nload-jsx is a plug-n-play module that will dynamically parse all JSX imports. This will allow you to use JSX markup across your project without needing to worry about build or compile steps\n\n---\n\n## Features\n\n- No configuration / bundle step needed\n- plug-and-play with just ONE import\n- Import files(.jsx, .js) using JSX markup within your NodeJs projects\n\n## Bonus\n\n- Can insert `Import React from '{react}'` at the top of files that use JSX\n\n---\n\n# Install\n\n`yarn add load-jsx`\n**or**\n`npm install --save load-jsx`\n\n\n\n### constructor / setup\n\n\nThe first step to import the lib\n``` js\nrequire('load-jsx')\n```\nIf you want to have you React'ish libarty imported at the top of you JSX, use.\n``` js\nrequire('load-jsx')('preact')\n```\nthis will add \"import React from 'preact'\" for example\n\n##  You only need to `require('load-jsx')` once  on the first  JS file loaded ツ\n\n\n---\n\n\n# Example\n\n### index.js\n``` js\n//Enable JSX\nrequire(\"load-jsx\")(\"react\");\n\n//Load server\nrequire(\"./server\");\n```\n\n### Elem.jsx\n``` js\nconst Elem = () =\u003e (\u003c\u003e\n        \u003cdiv\u003eHi World\u003c/div\u003e\n        \u003cbutton onClick={(e) =\u003e alert('Hello You!')}\u003eClick!\u003c/button\u003e\n    \u003c/\u003e)\nexport default Elem\n```\n### server.js\n\n``` js\nimport ReactDOMServer from 'react-dom/server'\nimport express from 'express'\nimport Elem from './Elem.jsx'\n\nconst app = express()\n\napp.get('/', (req, res) =\u003e {\n    const jsx = ReactDOMServer.renderToString(\u003cElem /\u003e)\n\n    res.send(`\n        \u003c!DOCTYPE html\u003e\n        \u003chtml\u003e \u003cbody\u003e ${jsx} \u003c/body\u003e \u003c/html\u003e\n    `)\n})\n\napp.listen(3000, () =\u003e console.log(`App listening on http://localhost:3000}`))\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemeasandwich%2Fload-jsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemeasandwich%2Fload-jsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemeasandwich%2Fload-jsx/lists"}