> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modelence.com/llms.txt
> Use this file to discover all available pages before exploring further.

# createClientModule

[API Reference](https://docs.modelence.com/api-reference/modelence/client/functions/../../../index) / [modelence](https://docs.modelence.com/api-reference/modelence/client/functions/../../index) / [client](https://docs.modelence.com/api-reference/modelence/client/functions/../index) / createClientModule

> **createClientModule**\<`TModule`>(`moduleName`): `object`

Defined in: [packages/modelence/src/client/module.ts:88](https://github.com/modelence/modelence/blob/main/packages/modelence/src/client/module.ts#L88)

Creates a typed client accessor for a module's public configs, queries, and mutations.

Use `import type` to reference the module so no server code is bundled on the client.
Arg and return types for queries and mutations are inferred automatically from the
server-side handler signatures.

## Example

```ts theme={null}
// src/client/payments.ts
import type paymentsModule from '../server/payments';
import { createClientModule } from 'modelence/client';

export const payments = createClientModule<typeof paymentsModule>('payments');
```

```ts theme={null}
// src/components/Checkout.tsx
import { useQuery, useMutation } from '@tanstack/react-query';
import { payments } from '../client/payments';

// Typed config — public keys only, private and secret keys excluded:
const currency = payments.getConfig('currency'); // string | undefined

// Typed query — pass directly to useQuery:
const { data: products } = useQuery(payments.query('getProducts', { page: 1 }));

// Typed mutation — pass directly to useMutation:
const { mutate: charge } = useMutation(payments.mutation('charge'));
charge({ amount: 100 }); // args typed from handler signature
```

## Type Parameters

| Type Parameter |
| - |
| `TModule` *extends* `AnyModule` |

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `moduleName` | `string` | The module's name as passed to `new Module(name, ...)`. |

## Returns

| Name | Type | Description | Defined in |
| - | - | - | - |
| `getConfig()` | (`key`) => `undefined` \| `PublicKeyOf`\<`TModule`\[`"configSchema"`]>\[`K`] | - | [packages/modelence/src/client/module.ts:90](https://github.com/modelence/modelence/blob/main/packages/modelence/src/client/module.ts#L90) |
| `infiniteQuery()` | (`name`, `getArgs`) => `object` | Returns options for `useInfiniteQuery`. The `getArgs` callback receives the current `pageParam` and returns the args to pass to the query handler. Spread the result into `useInfiniteQuery` alongside `getNextPageParam`. Annotate the `pageParam` type in the callback so TypeScript can infer the page param type — no manual generic needed on `useInfiniteQuery`. | [packages/modelence/src/client/module.ts:134](https://github.com/modelence/modelence/blob/main/packages/modelence/src/client/module.ts#L134) |
| `mutation()` | (`name`) => `object` | - | [packages/modelence/src/client/module.ts:114](https://github.com/modelence/modelence/blob/main/packages/modelence/src/client/module.ts#L114) |
| `query()` | (`name`, ...`rest`) => `object` | - | [packages/modelence/src/client/module.ts:97](https://github.com/modelence/modelence/blob/main/packages/modelence/src/client/module.ts#L97) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.