### Install dependencies and run development server with bun Source: https://docs.solidjs.com/quick-start After creating the project, navigate to the project directory and run these commands to install dependencies and start the development server using bun. ```bash cd solid-project bun install bun run dev ``` -------------------------------- ### Install dependencies and run development server with deno Source: https://docs.solidjs.com/quick-start After creating the project, navigate to the project directory and run these commands to install dependencies and start the development server using deno. ```bash cd solid-project denp install denp run dev ``` -------------------------------- ### Run One-Time Browser Setup Source: https://docs.solidjs.com/reference/lifecycle/on-mount Example of performing browser-specific setup tasks, like logging the current URL, once the component has mounted. This code will only execute on the client. ```javascript import { onMount } from "solid-js"; function Example() { onMount(() => { // Browser-only code console.log(window.location.pathname); }); return
Mounted
; } ``` -------------------------------- ### Install dependencies and run development server with npm Source: https://docs.solidjs.com/quick-start After creating the project, navigate to the project directory and run these commands to install dependencies and start the development server using npm. ```bash cd solid-project npm install npm run dev ``` -------------------------------- ### Basic App Usage Example Source: https://docs.solidjs.com/solid-start/reference/entrypoints/app Demonstrates a basic setup for the App component using SolidJS Router and FileRoutes. ```APIDOC ## Examples ### Basic usage ```jsx import { Router } from "@solidjs/router"; import { FileRoutes } from "@solidjs/start/router"; export default function App() { return ( ); } ``` ``` -------------------------------- ### Install dependencies and run development server with pnpm Source: https://docs.solidjs.com/quick-start After creating the project, navigate to the project directory and run these commands to install dependencies and start the development server using pnpm. ```bash cd solid-project pnpm install pnpm dev ``` -------------------------------- ### Basic Router Setup with Layout and Route Source: https://docs.solidjs.com/solid-router/reference/components/router Demonstrates a basic Solid Router setup with a root layout component and a simple home route. This example shows how to render a layout around your routes and define a default path. ```jsx import { render } from "solid-js/web"; import { Route, Router } from "@solidjs/router"; function Layout(props) { return ( <>

Root header

{props.children} ); } render( () => (

Home

} />
), document.getElementById("root")! ); ``` -------------------------------- ### Install dependencies and run development server with yarn Source: https://docs.solidjs.com/quick-start After creating the project, navigate to the project directory and run these commands to install dependencies and start the development server using yarn. ```bash cd solid-project yarn install yarn dev ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/solid-start/reference/entrypoints/entry-server This example demonstrates a basic setup for `entry-server.tsx`, including the import of necessary components and the definition of a `Document` component. The `Document` component is a standard HTML structure that includes placeholders for assets, the application's children, and scripts. ```APIDOC ## Basic Usage ### Description This example shows a typical configuration for `entry-server.tsx`. It imports `createHandler` and `StartServer` from `@solidjs/start/server`, defines a `Document` component for the HTML structure, and then exports the handler created by `createHandler`. ### Code ```typescript import { createHandler, StartServer } from "@solidjs/start/server"; function Document(props) { return ( {props.assets}
{props.children}
{props.scripts} ); } export default createHandler((event) => ); ``` ### Related - `createHandler` - `StartServer` ``` -------------------------------- ### Import GET from SolidStart Source: https://docs.solidjs.com/solid-start/reference/server/get Import the GET utility from the @solidjs/start package. ```javascript import { GET } from "@solidjs/start"; ``` -------------------------------- ### Install Solid Meta with deno Source: https://docs.solidjs.com/solid-meta/getting-started/installation-and-setup Use this command to install Solid Meta with deno. ```bash deno add npm:@solidjs/meta ``` -------------------------------- ### Basic SolidStart App with Router Source: https://docs.solidjs.com/solid-start/reference/entrypoints/app A fundamental example of an app.tsx component that sets up the Solid Router and includes file-based routes. Ensure @solidjs/router is installed. ```typescript import { Router } from "@solidjs/router"; import { FileRoutes } from "@solidjs/start/router"; export default function App() { return ( ); } ``` -------------------------------- ### Basic Client Entrypoint Example Source: https://docs.solidjs.com/solid-start/reference/entrypoints/entry-client A complete example demonstrating how to import and use `mount` and `StartClient` to initialize the SolidStart client application in the DOM. ```typescript import { mount, StartClient } from "@solidjs/start/client"; mount(() => , document.getElementById("app")!); ``` -------------------------------- ### Install Solid Router with deno Source: https://docs.solidjs.com/solid-router/getting-started/installation-and-setup Use this command to install Solid Router with deno. ```bash deno add npm:@solidjs/router ``` -------------------------------- ### Install Solid Meta with bun Source: https://docs.solidjs.com/solid-meta/getting-started/installation-and-setup Use this command to install Solid Meta using bun. ```bash bun i @solidjs/meta ``` -------------------------------- ### Install Solid Meta with npm Source: https://docs.solidjs.com/solid-meta/getting-started/installation-and-setup Use this command to install Solid Meta using npm. ```bash npm i @solidjs/meta ``` -------------------------------- ### Install Solid Meta with pnpm Source: https://docs.solidjs.com/solid-meta/getting-started/installation-and-setup Use this command to install Solid Meta using pnpm. ```bash pnpm i @solidjs/meta ``` -------------------------------- ### Install Solid Meta with yarn Source: https://docs.solidjs.com/solid-meta/getting-started/installation-and-setup Use this command to install Solid Meta using yarn. ```bash yarn add @solidjs/meta ``` -------------------------------- ### Install TypeScript with bun Source: https://docs.solidjs.com/configuration/typescript Install TypeScript as a development dependency using bun. ```bash bun i typescript -d ``` -------------------------------- ### Install Solid Router with bun Source: https://docs.solidjs.com/solid-router/getting-started/installation-and-setup Use this command to install Solid Router using bun. ```bash bun i @solidjs/router ``` -------------------------------- ### Install Firebase CLI with deno Source: https://docs.solidjs.com/guides/deployment-options/firebase Install the Firebase command-line tool globally using deno. ```bash deno add npm:firebase-tools -g ``` -------------------------------- ### Install TypeScript with deno Source: https://docs.solidjs.com/configuration/typescript Install TypeScript as a development dependency using deno. ```bash deno add npm:typescript -D ``` -------------------------------- ### Install Firebase CLI with bun Source: https://docs.solidjs.com/guides/deployment-options/firebase Install the Firebase command-line tool globally using bun. ```bash bun i firebase-tools -g ``` -------------------------------- ### Install SASS with bun Source: https://docs.solidjs.com/guides/styling-components/sass Install SASS as a development dependency using bun. ```bash bun i sass -d ``` -------------------------------- ### Install Solid Router with npm Source: https://docs.solidjs.com/solid-router/getting-started/installation-and-setup Use this command to install Solid Router using npm. ```bash npm i @solidjs/router ``` -------------------------------- ### A Component Basic Usage Example Source: https://docs.solidjs.com/solid-router/reference/components/a A practical example demonstrating how to use the A component for navigation within a Solid Router application. ```APIDOC ## Examples ### Basic usage ```jsx import { A, Route, Router } from "@solidjs/router"; function Layout(props) { return ( <> {props.children} ); } export default function App() { return (

Home

} />

Docs

} />
); } ``` ``` -------------------------------- ### Install Solid Router with yarn Source: https://docs.solidjs.com/solid-router/getting-started/installation-and-setup Use this command to install Solid Router using yarn. ```bash yarn add @solidjs/router ``` -------------------------------- ### Install Solid Router with pnpm Source: https://docs.solidjs.com/solid-router/getting-started/installation-and-setup Use this command to install Solid Router using pnpm. ```bash pnpm i @solidjs/router ``` -------------------------------- ### Install Netlify CLI with Deno Source: https://docs.solidjs.com/guides/deployment-options/netlify Install the Netlify CLI globally using Deno. This command is required before using Netlify CLI commands. ```bash deno add npm:netlify-cli -g ``` -------------------------------- ### Install LESS Source: https://docs.solidjs.com/guides/styling-components/less Install LESS as a development dependency using npm, pnpm, yarn, bun, or deno. ```bash npm i less -D ``` ```bash pnpm i less -D ``` ```bash yarn add less -D ``` ```bash bun i less -d ``` ```bash deno add npm:less -D ``` -------------------------------- ### Install Netlify CLI with Bun Source: https://docs.solidjs.com/guides/deployment-options/netlify Install the Netlify CLI globally using Bun. This command is required before using Netlify CLI commands. ```bash bun i netlify-cli -g ``` -------------------------------- ### Install Tailwind CSS with deno Source: https://docs.solidjs.com/guides/styling-components/tailwind Install Tailwind CSS and its PostCSS plugin as development dependencies using deno. ```bash deno add npm:tailwindcss @tailwindcss/postcss postcss -D ``` -------------------------------- ### Install Testing Dependencies with bun Source: https://docs.solidjs.com/guides/testing Install vitest, jsdom, @solidjs/testing-library, @testing-library/user-event, and @testing-library/jest-dom as development dependencies using bun. ```bash bun i vitest jsdom @solidjs/testing-library @testing-library/user-event @testing-library/jest-dom -d ``` -------------------------------- ### Build a writable derived signal example Source: https://docs.solidjs.com/reference/secondary-primitives/create-computed An example demonstrating how to use createComputed to build a writable derived signal. ```APIDOC ### Build a writable derived signal ``` import { createComputed, createSignal } from "solid-js"; function createWritableMemo(fn: () => T) { const [value, setValue] = createSignal(fn()); createComputed(() => { setValue(fn()); }); return value; } function Counter() { const [count, setCount] = createSignal(1); const double = createWritableMemo(() => count() * 2); return ( <>

{double()}

); } ``` ``` -------------------------------- ### Install Testing Dependencies with npm Source: https://docs.solidjs.com/guides/testing Install vitest, jsdom, @solidjs/testing-library, @testing-library/user-event, and @testing-library/jest-dom as development dependencies using npm. ```bash npm i vitest jsdom @solidjs/testing-library @testing-library/user-event @testing-library/jest-dom -D ``` -------------------------------- ### Basic SolidStart Server Entry Example Source: https://docs.solidjs.com/solid-start/reference/entrypoints/entry-server A complete example of `entry-server.tsx` demonstrating the import of `createHandler` and `StartServer`, a basic `Document` component for SSR, and the default export of the handler. ```typescript import { createHandler, StartServer } from "@solidjs/start/server"; function Document(props) { return ( {props.assets}
{props.children}
{props.scripts} ); } export default createHandler((event) => ); ``` -------------------------------- ### Install Project Dependencies Source: https://docs.solidjs.com/solid-start/getting-started After initializing your project and choosing a template, run this command to install all necessary dependencies. Select the command corresponding to your chosen package manager. ```bash npm i ``` ```bash pnpm i ``` ```bash yarn i ``` ```bash bun i ``` ```bash deno i ``` -------------------------------- ### Install Vercel CLI with deno Source: https://docs.solidjs.com/guides/deployment-options/vercel Install the Vercel CLI globally using deno. This command is used to manage Vercel deployments from your terminal. ```bash deno add npm:vercel -g ``` -------------------------------- ### Install Zerops CLI globally with deno Source: https://docs.solidjs.com/guides/deployment-options/zerops Install the Zerops CLI globally using deno. This command makes the `zcli` command available system-wide. ```bash deno add npm:@zerops/zcli -g ``` -------------------------------- ### Preloading Nested Lazy Components Example Source: https://docs.solidjs.com/reference/component-apis/lazy Illustrates how to use the `preload` method on a lazy component to start loading its module when a user interaction occurs, such as hovering over a button. ```APIDOC ```jsx import { createSignal, lazy, Show, Suspense } from "solid-js"; const Nested = lazy(() => import("./Nested")); const ComponentWithPreload = () => { const [showNested, setShowNested] = createSignal(false); return (
Loading nested component...

}>
); }; ``` ``` -------------------------------- ### Install Netlify CLI with npm Source: https://docs.solidjs.com/guides/deployment-options/netlify Install the Netlify CLI globally using npm. This command is required before using Netlify CLI commands. ```bash npm i netlify-cli -g ``` -------------------------------- ### Install Zerops CLI on Windows Source: https://docs.solidjs.com/guides/deployment-options/zerops Install the Zerops CLI on Windows using PowerShell. This command downloads and executes the installation script. ```powershell irm https://zerops.io/zcli/install.ps1 | iex ``` -------------------------------- ### Initialize SolidStart Project Source: https://docs.solidjs.com/solid-start/getting-started Use these commands to create a new SolidStart project. Choose the package manager that suits your workflow. ```bash npm init solid ``` ```bash pnpm create solid ``` ```bash yarn create solid ``` ```bash bun create solid ``` ```bash deno init --npm solid ``` -------------------------------- ### Install Wrangler CLI Globally (bun) Source: https://docs.solidjs.com/guides/deployment-options/cloudflare Install the Wrangler command-line tool globally using bun. This is a modern alternative for installing the CLI. ```bash bun i wrangler -g ``` -------------------------------- ### Create a new Solid project with deno Source: https://docs.solidjs.com/quick-start Use this command to initialize a new Solid project with deno. The CLI will prompt for project configuration. ```bash deno init --npm solid ``` -------------------------------- ### Install Wrangler CLI Globally (yarn) Source: https://docs.solidjs.com/guides/deployment-options/cloudflare Install the Wrangler command-line tool globally using yarn. This is another alternative for installing the CLI. ```bash yarn add wrangler -g ``` -------------------------------- ### Install Wrangler CLI Globally (pnpm) Source: https://docs.solidjs.com/guides/deployment-options/cloudflare Install the Wrangler command-line tool globally using pnpm. This is an alternative to npm for installing the CLI. ```bash pnpm i wrangler -g ``` -------------------------------- ### Create a new Solid project with npm Source: https://docs.solidjs.com/quick-start Use this command to initialize a new Solid project with npm. The CLI will prompt for project configuration. ```bash npm init solid ``` -------------------------------- ### Install Zerops CLI on Linux/MacOS Source: https://docs.solidjs.com/guides/deployment-options/zerops Install the Zerops CLI on Linux or MacOS using curl. This command downloads and executes the installation script. ```bash curl -L https://zerops.io/zcli/install.sh | sh ``` -------------------------------- ### Creating a Context Provider Source: https://docs.solidjs.com/reference/component-apis/create-context Example demonstrating how to create a Provider component for a context. ```javascript import { createContext } from "solid-js"; const CounterContext = createContext<{ count: number }>(); function CounterProvider(props) { return ( {props.children} ); } ``` -------------------------------- ### GET Type Definition Source: https://docs.solidjs.com/solid-start/reference/server/get The type definition for the GET utility, showing it accepts a function and returns a function with the same signature but with the return type of the function's GET property. ```typescript function GET any>( fn: T ): (...args: Parameters) => ReturnType; ``` -------------------------------- ### SolidJS App with MetaProvider and Head Tags Source: https://docs.solidjs.com/solid-meta/getting-started/installation-and-setup Example of setting up Solid Meta by wrapping the application with MetaProvider and rendering Title, Link, and Meta components. ```jsx import { MetaProvider, Title, Link, Meta } from "@solidjs/meta"; const App = () => (
Title of page
); ``` -------------------------------- ### Install TypeScript with yarn Source: https://docs.solidjs.com/configuration/typescript Install TypeScript as a development dependency using yarn. ```bash yarn add typescript -D ``` -------------------------------- ### Create a new Solid project with bun Source: https://docs.solidjs.com/quick-start Use this command to initialize a new Solid project with bun. The CLI will prompt for project configuration. ```bash bun create solid ``` -------------------------------- ### Install TypeScript with pnpm Source: https://docs.solidjs.com/configuration/typescript Install TypeScript as a development dependency using pnpm. ```bash pnpm i typescript -D ``` -------------------------------- ### Install TypeScript with npm Source: https://docs.solidjs.com/configuration/typescript Install TypeScript as a development dependency using npm. ```bash npm i typescript -D ``` -------------------------------- ### Full Task List Application Example Source: https://docs.solidjs.com/guides/complex-state-management A complete SolidJS application demonstrating complex state management with `createStore`, `setState`, `createEffect`, `produce`, and reactive UI updates. ```javascript import { For, createEffect, Show } from "solid-js"; import { createStore, produce } from "solid-js/store" const App = () => { let input; // lets you target the input value const [state, setState] = createStore({ tasks: [], numberOfTasks: 0, }); const addTask = (text) => { setState("tasks", state.tasks.length, { id: state.tasks.length, text, completed: false, }); }; const toggleTask = (id) => { setState( "tasks", (task) => task.id === id, produce((task) => { task.completed = !task.completed; }) ); }; createEffect(() => { setState("numberOfTasks", state.tasks.length); }); return ( <>

My Task List for Today

You have {state.numberOfTasks} task(s) for today!
{(task) => { const { id, text } = task; return (
toggleTask(task.id)} /> {text}
); }}
); }; export default App; ``` -------------------------------- ### Install SASS with deno Source: https://docs.solidjs.com/guides/styling-components/sass Install SASS as a development dependency using deno. ```bash deno add npm:sass -D ``` -------------------------------- ### Setup the Router Component Source: https://docs.solidjs.com/guides/routing-and-navigation Begin your application by rendering the `` component to match URLs and display the correct page. ```typescript import { render } from "solid-js/web"; import { Router } from "@solidjs/router"; render(() => , document.getElementById("root")); ``` -------------------------------- ### Install SASS with yarn Source: https://docs.solidjs.com/guides/styling-components/sass Install SASS as a development dependency using yarn. ```bash yarn add sass -D ``` -------------------------------- ### Install SASS with pnpm Source: https://docs.solidjs.com/guides/styling-components/sass Install SASS as a development dependency using pnpm. ```bash pnpm i sass -D ``` -------------------------------- ### Basic StartClient Usage with Mount Source: https://docs.solidjs.com/solid-start/reference/client/start-client Mount the SolidStart application using StartClient and the mount function. Ensure the target element with id 'app' exists in your HTML. ```typescript import { mount, StartClient } from "@solidjs/start/client"; mount(() => , document.getElementById("app")!); ``` -------------------------------- ### Create a new Solid project with pnpm Source: https://docs.solidjs.com/quick-start Use this command to initialize a new Solid project with pnpm. The CLI will prompt for project configuration. ```bash pnpm create solid ``` -------------------------------- ### Install SASS with npm Source: https://docs.solidjs.com/guides/styling-components/sass Install SASS as a development dependency using npm. ```bash npm i sass -D ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/solid-router/reference/components/hash-router Demonstrates a simple implementation of HashRouter with a single route. ```APIDOC ## Examples ### Basic usage ```typescript import { render } from "solid-js/web"; import { HashRouter, Route } from "@solidjs/router"; render( () => (

Home

} />
), document.getElementById("root")! ); ``` ``` -------------------------------- ### Prefilled Arguments Example Source: https://docs.solidjs.com/solid-router/reference/data-apis/action Illustrates using the `with` method of an action to create a new action with pre-filled leading arguments, useful for user-specific actions. ```APIDOC ## Prefilled arguments ``` import { action } from "@solidjs/router"; const addTodo = action(async (userId: string, data: URLSearchParams) => { return { userId, title: data.get("title")?.toString(), }; }, "addTodo"); function TodoForm(props: { userId: string }) { return (
); } ``` ``` -------------------------------- ### Install UnoCSS with deno Source: https://docs.solidjs.com/guides/styling-components/uno Install the UnoCSS package as a development dependency using deno. ```bash deno add npm:unocss -D ``` -------------------------------- ### Build Solid Project (npm) Source: https://docs.solidjs.com/guides/deployment-options/cloudflare Build your Solid project for production using the npm run build command. This prepares your project for deployment. ```bash npm run build ``` -------------------------------- ### Install UnoCSS with bun Source: https://docs.solidjs.com/guides/styling-components/uno Install the UnoCSS package as a development dependency using bun. ```bash bun i unocss -d ``` -------------------------------- ### Build Solid Project (bun) Source: https://docs.solidjs.com/guides/deployment-options/cloudflare Build your Solid project for production using the bun run build command. This is a modern alternative for building. ```bash bun run build ``` -------------------------------- ### Install UnoCSS with yarn Source: https://docs.solidjs.com/guides/styling-components/uno Install the UnoCSS package as a development dependency using yarn. ```bash yarn add unocss -D ``` -------------------------------- ### Install UnoCSS with pnpm Source: https://docs.solidjs.com/guides/styling-components/uno Install the UnoCSS package as a development dependency using pnpm. ```bash pnpm i unocss -D ``` -------------------------------- ### Install UnoCSS with npm Source: https://docs.solidjs.com/guides/styling-components/uno Install the UnoCSS package as a development dependency using npm. ```bash npm i unocss -D ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/reference/reactive-utilities/use-transition Demonstrates how to use the useTransition hook to manage loading states for data fetching with Suspense. ```typescript import { Suspense, createResource, createSignal, useTransition, } from "solid-js"; function Example() { const [userId, setUserId] = createSignal(1); const [user] = createResource(userId, async (id) => { const response = await fetch(`/api/users/${id}`); return response.json(); }); const [pending, start] = useTransition(); return ( <>
{pending() ? "Loading transition..." : "Ready"}
Loading user...

}>
{JSON.stringify(user(), null, 2)}
); } ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/reference/reactive-utilities/batch Demonstrates how to use the batch utility to update multiple signals and observe the batched effect on a memoized value. ```APIDOC ### Examples #### Basic usage ```javascript import { createSignal, createMemo, createEffect, batch } from "solid-js"; const [count, setCount] = createSignal(0); const [total, setTotal] = createSignal(0); const summary = createMemo(() => `${count()} / ${total()}`); createEffect(() => console.log(summary())); // logs "0 / 0" // Outside batch: setCount(1); // logs "1 / 0" setTotal(5); // logs "1 / 5" // Inside batch: batch(() => { setCount(1); setTotal(5); }); // logs "1 / 5" ``` ``` -------------------------------- ### Import mount and StartClient Source: https://docs.solidjs.com/solid-start/reference/entrypoints/entry-client Imports the necessary functions and components from the SolidStart client library. ```typescript import { mount, StartClient } from "@solidjs/start/client"; ``` -------------------------------- ### Initialize Netlify Project Source: https://docs.solidjs.com/guides/deployment-options/netlify Run this command in your project's root directory to initialize Netlify deployment. You will be prompted to authenticate and configure build settings, including the deploy directory. ```bash netlify init ``` -------------------------------- ### Basic useTransition Example Source: https://docs.solidjs.com/reference/reactive-utilities/use-transition Demonstrates basic usage of useTransition to manage loading states when fetching user data. It shows how to update a signal and display a loading indicator while the transition is in progress. ```javascript import { Suspense, createResource, createSignal, useTransition, } from "solid-js"; function Example() { const [userId, setUserId] = createSignal(1); const [user] = createResource(userId, async (id) => { const response = await fetch(`/api/users/${id}`); return response.json(); }); const [pending, start] = useTransition(); return ( <>
{pending() ? "Loading transition..." : "Ready"}
Loading user...

}>
{JSON.stringify(user(), null, 2)}
); } ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/reference/reactive-utilities/create-root Demonstrates how to use createRoot to create an owned context for managing reactive state and effects. The `dispose` function is called to clean up the context. ```typescript import { createSignal, createEffect, createRoot } from "solid-js"; function createCounter(initial = 0) { const [count, setCount] = createSignal(initial); createEffect(() => { console.log(`Count changed, new value: ${count()}`); }); function increment() { setCount((c) => c + 1); } function reset() { setCount(initial); } return { count, increment, reset }; } test("createCounter works correctly", () => { createRoot((dispose) => { const { count, increment, reset } = createCounter(10); expect(count()).toBe(10); increment(); expect(count()).toBe(11); reset(); expect(count()).toBe(10); dispose(); }); }); ``` -------------------------------- ### Import StartServer Component Source: https://docs.solidjs.com/solid-start/reference/server/start-server Import the StartServer component from the @solidjs/start/server package. ```javascript import { StartServer } from "@solidjs/start/server"; ``` -------------------------------- ### Install Solid Router Source: https://docs.solidjs.com/guides/routing-and-navigation Install the Solid Router package using your preferred package manager. ```bash npm i @solidjs/router ``` ```bash pnpm i @solidjs/router ``` ```bash yarn add @solidjs/router ``` ```bash bun i @solidjs/router ``` ```bash deno add npm:@solidjs/router ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/solid-router/reference/data-apis/action Demonstrates how to use the `action` API to create a form submission handler for adding a todo item. ```APIDOC ## Basic usage ``` import { action } from "@solidjs/router"; const addTodo = action(async (data: URLSearchParams) => { return data.get("title")?.toString(); }, "addTodo"); function TodoForm() { return (
); } ``` ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/solid-router/reference/data-apis/query Demonstrates how to use the `query` function to cache an asynchronous data fetching operation and how to generate a cache key. ```APIDOC ## Examples ### Basic usage ``` import { query } from "@solidjs/router"; const getUserProfile = query(async (userId: string) => { const response = await fetch(`/api/users/${encodeURIComponent(userId)}`); const json = await response.json(); if (!response.ok) { throw new Error(json?.message ?? "Failed to load user profile."); } return json as { name: string }; }, "userProfile"); const key = getUserProfile.keyFor("123"); ``` ``` -------------------------------- ### Install Firebase CLI with yarn Source: https://docs.solidjs.com/guides/deployment-options/firebase Install the Firebase command-line tool globally using yarn. ```bash yarn add firebase-tools -g ``` -------------------------------- ### Run SolidStart Application Locally Source: https://docs.solidjs.com/solid-start/getting-started Execute this command to start the development server and run your SolidStart application. The application will typically be available at http://localhost:3000. ```bash npm run dev ``` ```bash pnpm dev ``` ```bash yarn dev ``` ```bash bun run dev ``` ```bash deno run dev ``` -------------------------------- ### Install Firebase CLI with pnpm Source: https://docs.solidjs.com/guides/deployment-options/firebase Install the Firebase command-line tool globally using pnpm. ```bash pnpm i firebase-tools -g ``` -------------------------------- ### Install Firebase CLI with npm Source: https://docs.solidjs.com/guides/deployment-options/firebase Install the Firebase command-line tool globally using npm. ```bash npm i firebase-tools -g ``` -------------------------------- ### Import createHandler and StartServer Source: https://docs.solidjs.com/solid-start/reference/entrypoints/entry-server Imports the necessary functions `createHandler` and `StartServer` from the `@solidjs/start/server` package. ```typescript import { createHandler, StartServer } from "@solidjs/start/server"; ``` -------------------------------- ### createDynamic Example Source: https://docs.solidjs.com/reference/components/create-dynamic Provides a practical example of using createDynamic to render different views based on a signal. ```APIDOC ## Example ``` import { createSignal } from "solid-js"; const views = { red: (props: { label: string }) => (

{props.label}

), blue: (props: { label: string }) => (

{props.label}

), }; function App() { const [selected, setSelected] = createSignal("red"); return ( <> {createDynamic(() => views[selected()], { label: "Selected view" })} ); } ``` ``` -------------------------------- ### Implement GraphQL API Route in SolidStart Source: https://docs.solidjs.com/solid-start/building-your-application/api-routes Define a GraphQL schema and resolvers, then export a handler function for API routes. This example demonstrates setting up a basic GraphQL API. ```typescript import { buildSchema, graphql } from "graphql"; import type { APIEvent } from "@solidjs/start/server"; // Define GraphQL Schema const schema = buildSchema(` type Message { message: String } type Query { hello(input: String): Message goodbye: String } `); // Define GraphQL Resolvers const rootValue = { hello: () => { return { message: "Hello World", }; }, goodbye: () => { return "Goodbye"; }, }; // request handler const handler = async (event: APIEvent) => { // get request body const body = await new Response(event.request.body).json(); // pass query and save results const result = await graphql({ rootValue, schema, source: body.query }); // send query result return result; }; export const GET = handler; export const POST = handler; ``` -------------------------------- ### Install Tailwind CSS with bun Source: https://docs.solidjs.com/guides/styling-components/tailwind Install Tailwind CSS and its PostCSS plugin as development dependencies using bun. ```bash bun i tailwindcss @tailwindcss/postcss postcss -d ``` -------------------------------- ### Basic Usage Example Source: https://docs.solidjs.com/reference/component-apis/lazy Demonstrates how to use the `lazy` function to dynamically import a component and render it within a `Suspense` boundary, providing a fallback UI. ```APIDOC ```jsx import { lazy, Suspense } from "solid-js"; const ComponentA = lazy(() => import("./ComponentA")); function App(props: { title: string }) { return ( Loading...

}>
); } ``` ``` -------------------------------- ### createResource with Actions (mutate and refetch) Source: https://docs.solidjs.com/reference/basic-reactivity/create-resource Illustrates how to use the `mutate` and `refetch` actions returned by createResource. `refetch` re-runs the fetcher, and `mutate` allows for manual, optimistic updates of the resource's value. ```javascript const [posts, { refetch, mutate }] = createResource(fetchPosts); // Manual refetch await refetch(); // Optimistic update mutate((posts) => [...posts, newPost]); ``` -------------------------------- ### Install Tailwind CSS with yarn Source: https://docs.solidjs.com/guides/styling-components/tailwind Install Tailwind CSS and its PostCSS plugin as development dependencies using yarn. ```bash yarn add tailwindcss @tailwindcss/postcss postcss -D ``` -------------------------------- ### Install Tailwind CSS with pnpm Source: https://docs.solidjs.com/guides/styling-components/tailwind Install Tailwind CSS and its PostCSS plugin as development dependencies using pnpm. ```bash pnpm i tailwindcss @tailwindcss/postcss postcss -D ```