### Install create-nube-app with NPM Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/create-nube-app/README.md Use this command to start a new NubeSDK project using NPM. ```sh npm create nube-app@latest ``` -------------------------------- ### Install create-nube-app with Yarn Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/create-nube-app/README.md Use this command to start a new NubeSDK project using Yarn. ```sh yarn create nube-app ``` -------------------------------- ### Install create-nube-app with PNPM Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/create-nube-app/README.md Use this command to start a new NubeSDK project using PNPM. ```sh pnpm create nube-app ``` -------------------------------- ### Install @tiendanube/nube-sdk-ui Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/ui/README.md Install the @tiendanube/nube-sdk-ui package and its peer dependency @tiendanube/nube-sdk-types. ```sh npm install @tiendanube/nube-sdk-ui @tiendanube/nube-sdk-types ``` -------------------------------- ### Interactive create-nube-app Usage Example Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/create-nube-app/README.md This example demonstrates the interactive prompts when creating a new NubeSDK application, including project naming, template selection, and Git initialization. ```sh $ npm create nube-app@latest ◆ What is the project's name? │ my-nube-app │ ◆ Select a template: │ ● Minimal │ ○ Minimal with UI │ ○ Minimal with UI in JSX │ ◇ Initialize git repository? │ Yes ``` -------------------------------- ### Install dependencies Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/nube-devtools/README.md Install the required project dependencies using npm. ```bash npm install ``` -------------------------------- ### Example Project Structure Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/create-nube-app/README.md This outlines the typical directory and file structure generated by `create-nube-app` for a new NubeSDK project. ```sh my-nube-app/ ├── .vscode/ │ ├── extensions.json │ └── settings.json ├── src/ │ ├── main.ts │ └── main.test.ts ├── .gitignore ├── biome.json ├── package.json ├── README.md ├── tsconfig.json ├── tsup.config.js └── vitest.config.ts ``` -------------------------------- ### Run NubeSDK in development mode Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/examples/age-confirmation.md Starts a live server for local development of your application. ```bash npm run dev ``` -------------------------------- ### Install @tiendanube/nube-sdk-jsx dependencies Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/jsx/README.md Install the package along with its required peer dependencies. ```sh npm install @tiendanube/nube-sdk-jsx @tiendanube/nube-sdk-ui @tiendanube/nube-sdk-types ``` -------------------------------- ### Install NubeSDK Types Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/types/README.md Install the @tiendanube/nube-sdk-types package as a development dependency. ```sh npm install -D @tiendanube/nube-sdk-types ``` -------------------------------- ### Creating a Complete Styled Component Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/styling.md Example demonstrating the integration of StyleSheet, styled components, and theme tokens in a single component. ```tsx import { styled, StyleSheet, theme } from "@tiendanube/nube-sdk-ui"; import { Box, Button, Text } from "@tiendanube/nube-sdk-jsx"; // Reusable styles const styles = StyleSheet.create({ container: { backgroundColor: theme.color.main.background, borderRadius: theme.border.radius, padding: "24px", }, title: { color: theme.color.main.foreground, fontSize: "24px", fontWeight: "bold", marginBottom: "16px", }, }); // Static styled component const StyledButton = styled(Button)` background-color: ${theme.color.accent}; color: white; padding: 12px 24px; border-radius: ${theme.border.radius}; border: 1px solid ${theme.border.color}; transition: all 0.2s; &:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } `; // Usage Welcome to NubeSDK Get Started ``` -------------------------------- ### Install Nube SDK UI Package Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/getting-started.md Install the Nube SDK UI package if your application has a user interface. This package provides UI components and utilities. ```bash npm install @tiendanube/nube-sdk-ui ``` ```bash yarn add @tiendanube/nube-sdk-ui ``` ```bash pnpm add @tiendanube/nube-sdk-ui ``` ```bash bun add @tiendanube/nube-sdk-ui ``` -------------------------------- ### Run Development Server with npm Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/getting-started.md Start the local development server using npm. This server is configured for easy debugging with embedded sourcemaps. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun run dev ``` -------------------------------- ### Install Tsup Bundler Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/getting-started.md Install tsup as a development dependency for bundling your application. Tsup is a simple and fast bundler recommended for Nube SDK projects. ```bash npm install -D tsup ``` ```bash yarn add -D tsup ``` ```bash pnpm add -D tsup ``` ```bash bun add -D tsup ``` -------------------------------- ### Create Nube App with CLI Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/examples/age-confirmation.md Use the NubeSDK CLI to create a new application. Ensure Node.js version 16 or higher is installed. ```bash npm create nube-app@latest ``` -------------------------------- ### Install NubeSDK Snippet Package Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/snippet/README.md Add the package as a development dependency to your project. ```bash npm install --save-dev @tiendanube/nube-sdk-snippet ``` -------------------------------- ### Create a UI Component Tree Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/ui/README.md Import and use various UI component functions to construct a declarative component tree. This example demonstrates creating a layout with text and an input field. ```ts import { box, col, row, field, img, txt, fragment } from "@tiendanube/nube-sdk-ui"; const componentTree = box({ children: [ row({ children: [ col({ children: txt({ children: "Hello, NubeSDK!" }) }), ], }), field({ name: "email", label: "Email" }) ] }); ``` -------------------------------- ### Install Nube SDK Types Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/getting-started.md Install the Nube SDK types package as a development dependency. This is required to access NubeSDK types in your project. ```bash npm install -D typescript @tiendanube/nube-sdk-types ``` ```bash yarn add -D typescript @tiendanube/nube-sdk-types ``` ```bash pnpm add -D typescript @tiendanube/nube-sdk-types ``` ```bash bun add -D typescript @tiendanube/nube-sdk-types ``` -------------------------------- ### Install Nube SDK JSX Package Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/getting-started.md Install the Nube SDK JSX package if you intend to use JSX syntax in your project. This enables JSX transformations and runtime. ```bash npm install @tiendanube/nube-sdk-jsx ``` ```bash yarn add @tiendanube/nube-sdk-jsx ``` ```bash pnpm add @tiendanube/nube-sdk-jsx ``` ```bash bun add @tiendanube/nube-sdk-jsx ``` -------------------------------- ### Listen to Cart Updates with NubeSDK Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/types/README.md Example of how to use NubeSDK types to listen for cart updates and access the cart state. Requires importing NubeSDK and NubeSDKState types. ```ts import type { NubeSDK, NubeSDKState } from "@tiendanube/nube-sdk-types"; function App(nube: NubeSDK) { nube.on("cart:update", (state: NubeSDKState) => { console.log("Cart updated:", state.cart); }); } ``` -------------------------------- ### Implement Textarea Event Handlers Source: https://github.com/tiendanube/nube-sdk/blob/main/packages/doc/docs/components/textarea.md Example of handling events using the NubeComponentTextareaEventHandler type. ```tsx import { Textarea } from "@tiendanube/nube-sdk-jsx"; import type { NubeComponentTextareaEventHandler } from "@tiendanube/nube-sdk-types"; const handleEvents: NubeComponentTextareaEventHandler = (event) => { const { type, value, state } = event; // Perform some action };