{"id":20682109,"url":"https://github.com/mohammedhrima/urajs","last_synced_at":"2025-09-27T04:31:31.419Z","repository":{"id":243453712,"uuid":"812477962","full_name":"mohammedhrima/UraJS","owner":"mohammedhrima","description":"Frontend framework built with JavaScript/TypeScript","archived":false,"fork":false,"pushed_at":"2024-11-28T17:18:35.000Z","size":108694,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-02T09:27:42.110Z","etag":null,"topics":["framework","front-end","frontend","javascript","open-source","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohammedhrima.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-06-09T02:25:48.000Z","updated_at":"2024-11-29T19:48:46.000Z","dependencies_parsed_at":"2024-11-21T19:30:39.537Z","dependency_job_id":null,"html_url":"https://github.com/mohammedhrima/UraJS","commit_stats":null,"previous_names":["mohammedhrima/transcendence","mohammedhrima/urajs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammedhrima%2FUraJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammedhrima%2FUraJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammedhrima%2FUraJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammedhrima%2FUraJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohammedhrima","download_url":"https://codeload.github.com/mohammedhrima/UraJS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234386955,"owners_count":18824171,"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":["framework","front-end","frontend","javascript","open-source","typescript"],"created_at":"2024-11-16T22:12:47.510Z","updated_at":"2025-09-27T04:31:31.413Z","avatar_url":"https://github.com/mohammedhrima.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./src/assets/logo.png\" alt=\"Logo\" width=\"200\"\u003e\n\u003c/p\u003e\n\n\n**UraJS** is a lightweight single-page application (SPA) framework designed to make building interactive and dynamic web applications intuitive and efficient.\n\nInspired by the simplicity of **React**, the directory-based routing of **Next.js**, UraJS introduces its own take on SPA development. Its directory-based routing system automatically generates routes from the file structure, streamlining navigation setup for developers.\n\nWith built-in support for **live reloading**, **state-driven UI updates**.\n\n## Summary\n- [Get Started](#get-started)\n- [Generate Route](#generate-component-or-route)\n- [Example Generated JSX](#example-generated-jsx)\n- [Folders Structure](#folders-structure)\n- [Configuration](#configuration)\n- [Navigate between routes](#navigate-between-routes)\n- [Navigate with Parameters](#navigate-with-parameters)\n- [Tailwind](#tailwind)\n- [Conditions `\u003cura-if\u003e/\u003cura-elif\u003e/\u003cura-else\u003e`](#conditions)\n- [Loops `\u003cura-loop\u003e`](#loops)\n- [Component Composition](#component-composition)\n- [Deploy using Docker](#deploy-using-docker)\n\n## Get Started\nTo get started with **UraJS**, follow these simple steps:\n1. **Clone the repository**:\n```bash\n   git clone https://github.com/mohammedhrima/UraJS\n```\n2. **Navigate to the project directory**:\n```bash\n   cd UraJS\n```\n3. **Install the dependencies**:\n```bash\n   npm install\n```\n4. **Start the development server**:\n```bash\n   npm start\n```\n5. **Open your browser** and visit http://localhost:17000 to see the app running.\n+ you should see something like this\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./src/assets/home-page.png\" alt=\"Logo\" width=\"800\"\u003e\n\u003c/p\u003e\n\n6. **all commands**:\n```bash\n  npm start #start server\n```\n```bash\n  npm run clear #clear outfile\n```\n```bash\n  npm run route #create route\n```\n```bash\n  npm run comp #create component\n```\n```bash\n  npm run build #to build\n```\n```bash\n  npm run config #change configuration\n```\n\n## Generate Route\nTo generate routes automatically, you can use the following commands:\n- To generate a **basic route and its CSS/SCSS file if neede**, run:\n    \n    ```bash\n      npm run route /helloworld\n    ```\n\n+ This will create \n`pages/helloworld/helloworld.[jsx|tsx]` mapped to the /helloworld route.\n`pages/helloworld/helloworld.[css|scss]` for styling the route.\nAfter generating the route and its styles, visit the route in the browser by navigating to the corresponding URL `http://localhost:17000/helloworld`\n\n- To generate a **nested route and its SCSS file**, run:\n    \n    ```bash\n      npm run route /helloworld/again\n    ```\n\n## Example Generated JSX\n+ Component:\n```js\n    import Ura from 'ura';\n    \n    function Component() {\n      const [render, State] = Ura.init();  // Initialize Ura and state management\n      const [getter, setter] = State(0);  // Declare a state with an initial value of 0\n    \n      return render(() =\u003e (\n        \u003cdiv className=\"component\"\u003e\n          \u003ch1\u003eHello from the Component component!\u003c/h1\u003e\n          \u003cbutton onclick={() =\u003e setter(getter() + 1)}\u003e\n            Click me [{getter()}]\n          \u003c/button\u003e\n        \u003c/div\u003e\n      ));\n    }\n    \n    export default Component;\n```\n+ Route: \u003cspan style=\"color:red\"\u003eRoute tag should have `\u003croot\u003e\u003c/route\u003e` so the can be viewed\u003c/span\u003e\n```js\n    function Route() {\n      document.title = \"Route Page\";\n      const [render, State] = Ura.init();\n      const [count, setCount] = State(0);\n      const [darkMode, setDarkMode] = State(true);\n\n      return render(() =\u003e (\n        \u003croot\u003e\n          \u003cdiv className={`home ${darkMode() ? 'dark' : 'light'}`}\u003e\n            \u003cheader className=\"navbar\"\u003e\n              \u003cdiv className=\"logo\"\u003eUraJS\u003c/div\u003e\n              \u003cnav\u003e\n                \u003ca href=\"https://github.com/mohammedhrima/UraJS/\" target=\"_blank\"\u003eGitHub\u003c/a\u003e\n                \u003ca onclick={() =\u003e setDarkMode(!darkMode())}\u003e\n                  {darkMode() ? 'Light Mode' : 'Dark Mode'}\n                \u003c/a\u003e\n              \u003c/nav\u003e\n            \u003c/header\u003e\n\n            \u003cmain className=\"body\"\u003e\n              \u003ch1\u003eWelcome to UraJS\u003c/h1\u003e\n              \u003cp className=\"subtitle\"\u003eLightweight. Reactive. Yours.\u003c/p\u003e\n              \u003cbutton onclick={() =\u003e setCount(count() + 1)}\u003e\n                Click me [{count()}]\n              \u003c/button\u003e\n            \u003c/main\u003e\n\n            \u003cfooter className=\"footer\"\u003e\n              \u003cp\u003eBuilt with 💙 using UraJS\u003c/p\u003e\n            \u003c/footer\u003e\n          \u003c/div\u003e\n        \u003c/root\u003e\n      ));\n    }\n   export default Route;\n```\n#### Explanation of the Code:\n1. State: \n- used to updated the view wherever the value change: `const [getter, setter] = State(initialValue); `\n- componenet can hold multiple states\n- essential for updating the view weh state change\n2. Rendering the Component:\n+ `return render(() =\u003e ( ... ))`: saves JSX component for future reconciliation.\n3. Event Handling:\n+ `\u003cbutton onclick={() =\u003e setter(getter() + 1)}\u003e`: onlick state change\n+ In UraJS, event names should be written in lowercase. This is the standard convention for handling events in JavaScript.\n    + For example:\n        + `onclick` for mouse clicks.\n        + `onchange` for input changes.\n        + `onkeyup` for key presses.\nFor a complete list of event names, check W3Schools JavaScript Events  (https://www.w3schools.com/jsref/obj_events.asp)\n4. `\u003croot\u003e\u003c/root\u003e` reference to the `\u003cdiv id=\"root\"\u003e\u003c/div\u003e` in ./src/index.html\n\n## Folders structure:\n```\n    UraJS/\n    ├── out/ # Production-ready transpiled JavaScript files\n    │   └── (All framework and app code transpiled to vanilla JS)\n    │\n    ├── scripts/ # scripts used by the framework.\n    │\n    ├── src/\n    │   ├── assets/ # Static assets\n    │   │   └── (image.png, ...)\n    │   │\n    │   ├── components/ # Reusable UI components\n    │   │   ├── Button/ # Example component\n    │   │   │   ├── Button.jsx\n    │   │   │   └── Button.css\n    │   │   └── (Other components...)\n    │   │\n    │   ├── pages/ # Route-based components\n    │   │   ├── home/ # Example route: /home\n    │   │   │   ├── home.jsx # Route component\n    │   │   │   └── home.css # Route-specific styles\n    │   │   │\n    │   │   ├── main.js # Application entry point\n    │   │   ├── main.scss # Global styles/variables\n    │   │   └── tailwind.css # Tailwind imports (if enabled)\n    │   │\n    │   ├── services/ # Business logic/services\n    │   │   ├── api.jsx # API service layer\n    │   │   └── events.js # Event bus/service (in developement)\n    │   │\n    │   └── ura/ # Framework frontend code\n    │\n    ├── tailwind.config.js # Tailwind CSS configuration\n    ├── ura.config.js # Framework configuration\n    ├── tsconfig.json # TypeScript configuration\n    └── package.json # Project dependencies and scripts\n             \n```\n\n## Configuration\n+ The `ura.config.js` file allows you to customize various settings for your project\n+ Default config:\n```js\n    typescript: \"disable\" \n    dirRouting: \"enable\"\n    defaultRoute: \"home\"\n    tailwind: \"disable\"\n    scss: \"disable\"\n    css: \"enable\"\n    port: 17000\n```\n+ to change it: run\n```bash\n  npm run config #change configuration\n```\n+ you will get a validation messages like this\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./src/assets/config.png\" alt=\"Logo\" width=\"500\"\u003e\n\u003c/p\u003e\n\n## Navigate between routes\n```bash\n    npm run route /home\n    npm run route /about\n    npm run comp /navbar\n```\n```js\n    // components/Navbar.jsx\n    import Ura from 'ura';\n    \n    function Navbar() {\n      const [render, State] = Ura.init();\n    \n      return render(() =\u003e (\n        \u003cnav className=\"navbar\"\u003e\n          \u003cul\u003e\n            \u003cli onclick={() =\u003e Ura.navigate(\"/home\")}\u003e\u003ca href=\"/home\"\u003eHome\u003c/a\u003e\u003c/li\u003e\n            \u003cli onclick={() =\u003e Ura.navigate(\"/about\")}\u003e\u003ca href=\"/about\"\u003eAbout\u003c/a\u003e\u003c/li\u003e\n          \u003c/ul\u003e\n        \u003c/nav\u003e\n      ));\n    }\n    \n    export default Navbar;\n```\n**Explanation of the navigate Hook:**\n\n+ `Ura.navigate` is a built-in function in UraJS that programmatically changes the current route of the app. When you call this function, it will update the URL and load the corresponding component.\n\n### Adding the Navbar to the Home Page\nOnce the `Navbar` component is created, you can include it in your `home` page component. For instance:\n\n```js\n    // pages/home/home.jsx\n    import Ura from 'ura';\n    import Navbar from '../../components/Navbar.js';\n    \n    function Home() {\n      const [render, State] = Ura.init();\n    \n      return render(() =\u003e (\n        \u003croot\u003e\n          \u003cdiv\u003e\n            \u003cNavbar /\u003e\n            \u003ch1\u003eWelcome to the Home Page!\u003c/h1\u003e\n          \u003c/div\u003e\n        \u003c/root\u003e\n      ));\n    }\n    \n    export default Home;\n```\n\n## Navigate with Parameters\n```bash\n    npm run route /home\n    npm run route /user\n    npm run comp /navbar\n```\nThis component uses Ura.navigate to navigate to a new page (`/user`) and passes the `name` and `email` parameters.\n```js\n    import Ura from 'ura';\n    \n    function Home() {\n      const [render, State] = Ura.init();\n    \n      return render(() =\u003e (\n        \u003croot\u003e\n          \u003cdiv className=\"home\"\u003e\n            \u003ch1\u003eWelcome to the Home Page!\u003c/h1\u003e\n            \u003cbutton onclick={() =\u003e Ura.navigate(\"/user\", { name: \"John Doe\", email: \"john.doe@example.com\" })}\u003e\n              Show Details\n            \u003c/button\u003e\n          \u003c/div\u003e\n        \u003c/root\u003e\n      ));\n    }\n    \n    export default Home;\n```\n#### Component That Receives and Visualizes the Parameters\nThis component receives the name and email parameters from the navigation and displays them.\n```js\n    import Ura from 'ura';\n    \n    function User() {\n      const { name, email } = Ura.getParams();\n      const [render, State] = Ura.init();\n\n      return render(() =\u003e (\n        \u003croot\u003e\n          \u003cdiv className=\"user\"\u003e\n            \u003ch1\u003eUser Name: {name}\u003c/h1\u003e\n            \u003cp\u003eEmail: {email}\u003c/p\u003e\n          \u003c/div\u003e\n        \u003c/root\u003e\n      ));\n    }\n    \n    export default user;\n\n```\n\n## Tailwind\n+ make sure to enbale the tailwind in config to see the change\n```js\n  import Ura from \"ura\"\n\n  function Button() {\n    const [render, State] = Ura.init();\n\n    return render(() =\u003e (\n      \u003cbutton className=\"px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-700 transition-colors duration-300\"\u003e\n        Click Me\n      \u003c/button\u003e\n    ));\n  }\n```\n\n## Conditions:\n- `ura-if`, `ura-elif`, `ura-else`\n- you can use them as tags `\u003cura-if\u003e`, `\u003cura-elif\u003e`, `\u003cura-else\u003e`\n- or you can use as attributes\n\n```js\n    import Ura from \"ura\";\n\n    function WeatherDisplay() {\n      const [render, State] = Ura.init();\n      const [getTemp, setTemp] = State(25); // Default temperature\n      const [isRaining, setIsRaining] = State(false);\n\n      return render(() =\u003e (\n        \u003croot\u003e\n          \u003cdiv className=\"weather-widget\"\u003e\n            \u003ch2\u003eWeather Conditions\u003c/h2\u003e\n            \n            {/* Tag syntax */}\n            \u003cura-if cond={getTemp() \u003e 30}\u003e\n              \u003cdiv className=\"alert\"\u003eHeat warning!\u003c/div\u003e\n            \u003c/ura-if\u003e\n            \u003cura-elif cond={getTemp() \u003c 0}\u003e\n              \u003cdiv className=\"alert\"\u003eFreezing temperatures!\u003c/div\u003e\n            \u003c/ura-elif\u003e\n            \u003cura-else\u003e\n              \u003cdiv\u003eNormal temperature range\u003c/div\u003e\n            \u003c/ura-else\u003e\n  \n            {/* Attribute syntax */}\n            \u003cdiv ura-if={isRaining()}\u003eBring an umbrella! ☔\u003c/div\u003e\n            \u003cdiv ura-else\u003eNo rain expected today\u003c/div\u003e\n  \n            {/* Shorthand if statement (ternary) */}\n            \u003cdiv\u003e\n              Current temperature: {getTemp()}°C - \n              {getTemp() \u003e 20 ? \" Warm\" : \" Cool\"}\n            \u003c/div\u003e\n  \n            {/* Controls to demo dynamic changes */}\n            \u003cdiv className=\"controls\"\u003e\n              \u003cbutton onClick={() =\u003e setTemp(getTemp() + 5)}\u003eIncrease Temp\u003c/button\u003e\n              \u003cbutton onClick={() =\u003e setTemp(getTemp() - 5)}\u003eDecrease Temp\u003c/button\u003e\n              \u003cbutton onClick={() =\u003e setIsRaining(!isRaining())}\u003e\n                Toggle Rain\n              \u003c/button\u003e\n            \u003c/div\u003e\n          \u003c/div\u003e\n        \u003c/root\u003e\n      ));\n    }\n\n    export default WeatherDisplay;\n```\n\n## Loops:\n- `\u003cloop\u003e` tag can be treated as any tag you can style it, add className etc...\n```js\n    function Card() {\n      const [render, State] = Ura.init();\n      const [getItems, setItems] = State([\"Milk\", \"Eggs\", \"Bread\", \"Fruits\"]);\n\n      return render(() =\u003e (\n        \u003croot\u003e\n          \u003cdiv className=\"shopping-list\"\u003e\n            \u003ch2\u003eGrocery Items\u003c/h2\u003e\n\n            {/* Tag syntax with \u003cura-loop\u003e tag won't be shown in the view*/}\n            \u003cura-loop on={getItems()}\u003e\n              {(item, index) =\u003e (\n                \u003cdiv key={index} className=\"item\"\u003e\n                  \u003cspan\u003e{index + 1}. {item}\u003c/span\u003e\n                  \u003cbutton onClick={() =\u003e setItems(getItems().filter((_, i) =\u003e i !== index))}\u003e\n                    Remove\n                  \u003c/button\u003e\n                \u003c/div\u003e\n              )}\n            \u003c/ura-loop\u003e\n            \n            {/* ura-loop as attribute div tag will be shown in the view even if the array is empty */}\n            \u003cdiv ura-loop={getItems()}\u003e\n              {(item, index) =\u003e (\n                \u003cdiv key={index} className=\"item\"\u003e\n                  \u003cspan\u003e{index + 1}. {item}\u003c/span\u003e\n                  \u003cbutton onClick={() =\u003e setItems(getItems().filter((_, i) =\u003e i !== index))}\u003e\n                    Remove\n                  \u003c/button\u003e\n                \u003c/div\u003e\n              )}\n            \u003c/div\u003e\n\n            {/* use map method */}\n            {getItems().map((item, index) =\u003e (\n              \u003cdiv key={index} className=\"item\"\u003e\n                \u003cspan\u003e{index + 1}. {item}\u003c/span\u003e\n                \u003cbutton onClick={() =\u003e setItems(getItems().filter((_, i) =\u003e i !== index))}\u003e\n                  Remove\n                \u003c/button\u003e\n              \u003c/div\u003e\n            ))}\n\n            \u003cbutton onClick={() =\u003e setItems([...getItems(), \"New Item\"])}\u003e\n              Add Item\n            \u003c/button\u003e\n          \u003c/div\u003e\n        \u003c/root\u003e\n      ));\n    }\n```\n\n## Component Composition\n+ example card component\n```js\n  import Ura from 'ura';\n  \n  function Card(props, children) {\n    const [render] = Ura.init();\n  \n    return render(() =\u003e (\n      \u003cdiv className=\"card\"\u003e\n        \u003ch2\u003e{props.title}\u003c/h2\u003e\n        {children}\n      \u003c/div\u003e\n    ));\n  }\n  export default Card;\n```\n```js\n  import Ura from 'ura';\n  import Card from '../../components/Card.js';\n  \n function Dashboard() {\n    const [render] = Ura.init();\n  \n    return render(() =\u003e (\n      \u003croot\u003e\n        \u003cCard title=\"User Info\"\u003e\n          \u003cp\u003eName: John Doe\u003c/p\u003e\n          \u003cp\u003eEmail: john@example.com\u003c/p\u003e\n        \u003c/Card\u003e\n  \n        \u003cCard title=\"Stats\"\u003e\n          \u003cul\u003e\n            \u003cli\u003ePosts: 34\u003c/li\u003e\n            \u003cli\u003eFollowers: 120\u003c/li\u003e\n          \u003c/ul\u003e\n        \u003c/Card\u003e\n      \u003c/root\u003e\n    ));\n  }\n export default Dashboard;\n```\n\n## Deploy using docker\n\n1. Build the Project\n+ To build the project and generate the necessary Docker configuration files, run the following command:\n```bash\n    npm run build\n```\nThis command will use Nginx to serve your static files and generate a docker directory with the following structure:\n```\n    docker/\n    ├── app/                # Contains all transpiled files (e.g., JavaScript, CSS, etc.)\n    ├── nginx/              # Contains the nginx configuration file\n    │   └── nginx.conf\n    ├── Dockerfile          # Dockerfile to build the application container\n    ├── docker-compose.yml  # Docker Compose file to set up and run the container\n    └── Makefile            # Makefile to run Docker container\n```\n\n2. Build and Run the Container\n\n+ After running npm run build, navigate to the docker directory:\n```bash\n    cd docker\n```\n+ To start the Docker container, run:\n```bash\n    make\n```\n3. Stop the Container\n```bash\n    make down\n```\n\n4. Clean Up Volumes and Remove Docker Images\n```\n    make clean\n```\n\n5. Check Nginx Configuration\n+ The Nginx configuration is in docker/nginx/nginx.conf. It serves the transpiled files\n+ Check the port in nginx.conf (e.g., listen 17000). The port is automatically selected during the build process by choosing the available one.\n+ After starting the container, open your browser and go to:\n```\n    http://localhost:17000\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammedhrima%2Furajs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammedhrima%2Furajs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammedhrima%2Furajs/lists"}