### Quick Start Commands Source: https://github.com/alibaba/rax/blob/master/examples/README.md Provides essential commands for installing dependencies, running the project in development mode, and building the project. ```shell npm install # dev mode npm run start # build mode npm run build ``` -------------------------------- ### Start Rax Project Development Source: https://github.com/alibaba/rax/blob/master/README.md These commands are used to navigate into the project directory, install dependencies, and start the local development server for a Rax project. ```sh cd npm install npm run start ``` -------------------------------- ### Install rax-server Source: https://github.com/alibaba/rax/blob/master/packages/rax-server/README.md Installs the rax-server package using npm. ```bash npm install rax-server --save ``` -------------------------------- ### Rax Miniapp Examples Source: https://github.com/alibaba/rax/blob/master/examples/README.md Demonstrates various Rax miniapp functionalities, including native custom components, plugin components, native pages, and runtime usage of compiled components. ```shell # with-miniapp-native-custom-component: Using miniapp native custom components (local components + npm components) # with-miniapp-plugin-component: Using miniapp plugin components + split-end build # with-miniapp-native-page: Using native pages # use-rax-compiled-component-in-runtime-miniapp: Rax miniapp runtime project using Rax compile-time components ``` -------------------------------- ### Basic Rax Usage Example Source: https://github.com/alibaba/rax/blob/master/packages/rax/README.md A simple example demonstrating how to create a component and render it to the DOM using Rax and the driver-dom package. It shows the basic structure of a Rax application. ```jsx import {createElement, render} from 'rax'; import * as DriverDOM from 'driver-dom'; function MyComponent() { return
Hello World
; } render(, document.body, { driver: DriverDOM }); ``` -------------------------------- ### Install Rax Source: https://github.com/alibaba/rax/blob/master/packages/rax/README.md Installs the Rax package using npm. This is the primary installation command for using Rax in your project. ```sh npm install --save rax ``` -------------------------------- ### Install rax-server-renderer Source: https://github.com/alibaba/rax/blob/master/packages/rax-server-renderer/README.md This snippet shows how to install the rax-server-renderer package using npm. ```sh $ npm install --save rax-server-renderer ``` -------------------------------- ### Create a New Rax Project Source: https://github.com/alibaba/rax/blob/master/README.md This command initializes a new Rax project using the create-rax tool. It's the starting point for building a new Rax application. ```sh npm init rax ``` -------------------------------- ### Install rax-redux Source: https://github.com/alibaba/rax/blob/master/packages/rax-redux/README.md Installs the rax-redux package using npm. ```sh npm install --save rax-redux ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/get-element/README.md Runs the Rax application in development mode, enabling hot reloading and easy debugging. Opens the application at http://localhost:9999. ```bash npm run start # Opens http://localhost:9999 ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/with-miniapp-plugin-component/README.md Runs the Rax application in development mode, enabling hot reloading and easy debugging. Opens the application at http://localhost:9999. ```bash npm run start # Opens http://localhost:9999 ``` -------------------------------- ### Install rax-test-renderer Source: https://github.com/alibaba/rax/blob/master/packages/rax-test-renderer/README.md Installs the rax-test-renderer package as a development dependency using npm. ```sh npm install --save-dev rax-test-renderer ``` -------------------------------- ### Install driver-webgl Source: https://github.com/alibaba/rax/blob/master/packages/driver-webgl/README.md Installs the WebGL driver for Rax using npm. ```bash $ npm install --save driver-webgl ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/page-lifecycle-with-router/README.md Runs the Rax application in development mode, enabling hot reloading and easy debugging. Opens the application at http://localhost:9999. ```bash npm run start # Opens http://localhost:9999 ``` -------------------------------- ### Install driver-dom Source: https://github.com/alibaba/rax/blob/master/packages/driver-dom/README.md Installs the driver-dom package using npm. This is the first step to using the DOM driver with Rax. ```bash npm install --save driver-dom ``` -------------------------------- ### Install driver-universal Source: https://github.com/alibaba/rax/blob/master/packages/driver-universal/README.md This snippet shows the command to install the driver-universal package using npm. ```bash npm install --save driver-universal ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/with-miniapp-native-custom-component/README.md Runs the Rax application in development mode, enabling hot reloading and easy debugging. Opens the application at http://localhost:9999. ```bash npm run start # Opens http://localhost:9999 ``` -------------------------------- ### Basic Usage of RaxServer Source: https://github.com/alibaba/rax/blob/master/packages/rax-server/README.md Demonstrates the basic setup and usage of RaxServer for server-side rendering with Node.js http module. ```javascript const http = require('http'); const RaxServer = require('rax-server'); const PORT = 8080; const server = new RaxServer({ // ... }); const app = new http.createServer((req, res) => { if (req.pathname === '/index') { server.render(req, res, { page: 'index' }); } else { // ... } }); app.listen(PORT, () => { console.log(`SSR running on port ${PORT}`); }); ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/event-handler/README.md Runs the Rax application in development mode, enabling hot reloading and easy debugging. Opens the application at http://localhost:9999. ```bash npm run start # Opens http://localhost:9999 ``` -------------------------------- ### Install driver-server with npm Source: https://github.com/alibaba/rax/blob/master/packages/driver-server/README.md Installs the driver-server package as a project dependency using npm. ```bash $ npm install --save driver-server ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/with-miniapp-native-page/README.md Runs the Rax application in development mode. This command starts a local development server, typically accessible at http://localhost:9999, and enables hot reloading for faster development cycles. ```bash npm run start ``` -------------------------------- ### Rax Document/Element APIs Source: https://github.com/alibaba/rax/blob/master/examples/README.md Shows how to use document and element related APIs, such as getElementXXX. ```shell # get-element: document/element getElementXXX related APIs ``` -------------------------------- ### Rax Lifecycle and Event Handling Source: https://github.com/alibaba/rax/blob/master/examples/README.md Illustrates the usage of application and page lifecycles, including routing, and demonstrates event binding for miniapp compilation. ```shell # app-lifecycle: Using app lifecycle # page-lifecycle-with-router: Using page lifecycle + router jump # event-handler: Event binding (compile-time miniapp) ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/app-lifecycle/README.md Runs the Rax application in development mode. This command starts a local development server, typically accessible at http://localhost:9999, and enables hot reloading for faster development cycles. ```bash npm run start ``` -------------------------------- ### Start Development Server Source: https://github.com/alibaba/rax/blob/master/examples/use-rax-compiled-component-in-runtime-miniapp/README.md Runs the Rax application in development mode. This command starts a local development server, typically accessible at http://localhost:9999, and enables hot reloading for faster development cycles. ```bash npm run start ``` -------------------------------- ### Install Weex Driver Source: https://github.com/alibaba/rax/blob/master/packages/driver-weex/README.md This snippet shows the npm command to install the Weex driver for Rax. ```bash npm install --save driver-weex ``` -------------------------------- ### Usage Example Source: https://github.com/alibaba/rax/blob/master/packages/rax-redux/README.md Demonstrates how to use the Provider component from rax-redux to connect a Rax application to a Redux store. ```js import { createElement, render } from 'rax'; import { Provider } from 'rax-redux'; import store from './store'; import App from './App'; render( ); ``` -------------------------------- ### Install Rax Types for TypeScript Source: https://github.com/alibaba/rax/blob/master/packages/rax/README.md Installs the TypeScript type definitions for Rax, enabling better type checking and autocompletion when using Rax with TypeScript. ```sh npm install --save-dev @types/rax ``` -------------------------------- ### Basic Usage of driver-universal in Rax Source: https://github.com/alibaba/rax/blob/master/packages/driver-universal/README.md This example demonstrates how to import and use the DriverUniversal in a Rax application to render a component. It includes importing necessary Rax modules and the driver itself. ```jsx import { createElement, render } from 'rax'; import View from 'rax-view'; import Image from 'rax-image'; import DriverUniversal from 'driver-universal'; function Example() { return ( ); } render(, null, { driver: DriverUniversal }); ``` -------------------------------- ### Rax Server-Side Rendering Example Source: https://github.com/alibaba/rax/blob/master/packages/driver-server/README.md Demonstrates how to use the ServerDriver for server-side rendering in a Rax application. It includes importing necessary components, defining a simple Rax component, and rendering it with the ServerDriver when running in a Node.js environment. ```jsx import {createElement, Component, render} from 'rax'; import ServerDriver from 'driver-server'; import {isNode} from 'universal-env'; class Example extends Component { render() { return (
); } } render(, null, { driver: isNode ? ServerDriver : null }); ``` -------------------------------- ### Use Weex Driver in Rax Source: https://github.com/alibaba/rax/blob/master/packages/driver-weex/README.md This example demonstrates how to import and use the Weex driver within a Rax component for rendering. ```jsx import {createElement, Component, render} from 'rax'; import * as WeexDriver from 'driver-weex'; class Example extends Component { render() { return (
); } } render(, null, { driver: WeexDriver }); ``` -------------------------------- ### Node.js Usage Examples Source: https://github.com/alibaba/rax/blob/master/packages/style-unit/README.md Demonstrates how to use the `convertUnit` function in a Node.js environment for both Web and Weex platforms. ```javascript convertUnit('500rpx', 'width', 'weex') ``` ```javascript convertUnit('500rpx', 'width', 'web') ``` -------------------------------- ### Basic Document Usage Source: https://github.com/alibaba/rax/blob/master/packages/rax-document/README.md Demonstrates the basic structure of a document using rax-document components like Root, Data, Style, and Script. This setup is suitable for standard web applications. ```jsx import { createElement } from 'rax'; import { Root, Data, Style, Script } from 'rax-document'; export default () => { return ( ssr-document-demo