SolidJS uses fine-grained reactivity — changes to a signal only update the specific DOM nodes and computations that depend on it, not entire components. UUID v7 IDs stored in SolidJS signals and stores participate in this reactive system efficiently. SolidStart provides the server-rendering layer where UUID v7 generation belongs. See UUID Generation Strategies for the server-vs-client principle.

Setup

npm create solid@latest
npm install uuid

SolidStart server function with UUID v7

// src/lib/orders.ts
"use server";
import { v7 as uuidv7 } from 'uuid';
import { db } from './db';
import { orders } from './schema';

export async function createOrder(customerId: string, total: number) {
  const order = {
    id: uuidv7(),  // "use server" — always runs on server
    customerId,
    total,
  };
  await db.insert(orders).values(order);
  return order;
}
// src/routes/orders.tsx
import { createAction } from '@solidjs/router';
import { createOrder } from '~/lib/orders';

const createOrderAction = createAction(createOrder);

export default function OrdersPage() {
  const [submitting, submit] = createOrderAction;

  return (
    <form onSubmit={(e) => {
      e.preventDefault();
      const fd = new FormData(e.currentTarget);
      submit(fd.get('customerId') as string, Number(fd.get('total')));
    }}>
      <input name="customerId" required />
      <input name="total" type="number" required />
      <button disabled={submitting()}>Create Order</button>
    </form>
  );
}

createStore with UUID v7 IDs

import { createStore } from 'solid-js/store';
import { v7 as uuidv7 } from 'uuid';
import { For } from 'solid-js';

interface Todo {
  id: string;
  text: string;
  done: boolean;
}

export function TodoList() {
  const [todos, setTodos] = createStore<Todo[]>([]);

  function addTodo(text: string) {
    // UUID v7 generated in event handler — safe (client-only)
    setTodos((prev) => [...prev, { id: uuidv7(), text, done: false }]);
  }

  function toggleTodo(id: string) {
    setTodos(
      (todo) => todo.id === id,   // fine-grained path: only matching todo updates
      'done',
      (done) => !done
    );
  }

  return (
    <ul>
      <For each={todos}>
        {(todo) => (
          <li onClick={() => toggleTodo(todo.id)}>
            {todo.text} — {todo.id.slice(0, 8)}…
          </li>
        )}
      </For>
    </ul>
  );
}

SolidJS’s createStore path-based updates (setTodos(predicate, 'done', updater)) only update the specific done field of the matching todo — not the entire list. UUID v7 id values serve as stable store keys.

SolidStart API route with UUID v7

// src/routes/api/orders.ts
import type { APIEvent } from '@solidjs/start/server';
import { v7 as uuidv7 } from 'uuid';
import { json } from '@solidjs/router';

export async function POST({ request }: APIEvent) {
  const body = await request.json();
  const order = { id: uuidv7(), ...body };
  await db.insert(orders).values(order);
  return json(order, { status: 201 });
}

Cursor pagination in SolidStart loaders

// src/routes/orders.tsx
import { createAsync, query } from '@solidjs/router';
import { db } from '~/lib/db';
import { orders } from '~/lib/schema';
import { gt } from 'drizzle-orm';

const getOrders = query(async (cursor?: string) => {
  "use server";
  const rows = await db
    .select()
    .from(orders)
    .where(cursor ? gt(orders.id, cursor) : undefined)
    .orderBy(orders.id)
    .limit(20);
  return rows;
}, 'orders');

export default function OrdersPage() {
  const data = createAsync(() => getOrders());
  return (
    <ul>
      <For each={data()}>
        {(order) => <li>{order.id} — {order.customer}</li>}
      </For>
    </ul>
  );
}

See UUID v7 for Cursor Pagination for the full keyset pattern.

Further reading

External references

Frequently asked questions

Is it safe to generate UUID v7 in a SolidJS component?

Only in server-rendered contexts (SolidStart server functions, API routes). In client-side SolidJS components, generate UUID v7 inside event handlers or createEffect — never at the top level of a component function that runs during SSR, as the server and client will produce different values. SolidStart server functions ("use server") are the cleanest pattern. See UUID Generation Strategies.

How does UUID v7 work with SolidJS signals?

A UUID v7 stored in a signal (const [id, setId] = createSignal(uuidv7())) behaves like any other signal value. SolidJS tracks which computations read id() and only re-runs those when setId() is called. This is more efficient than React's component-level re-renders for ID management in large lists.