3.45.2 β€’ Published 2 days ago

@ts-rest/solid-query v3.45.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

ts-rest

Introduction

ts-rest offers a simple way to define a contract for your API, which can be both consumed and implemented by your application, giving you end to end type safety without the hassle or code generation.

Features

  • End-to-end type safety πŸ›Ÿ
  • RPC-like client side API ⚑️
  • Small Bundle Size πŸ“‰
  • No Code Generation πŸƒβ€β™€οΈ
  • Zod support for runtime validation πŸ”’
  • Full optional OpenAPI integration πŸ“

Super Simple Example

Easily define your API contract somewhere shared

const contract = c.router({
  getPosts: {
    method: 'GET',
    path: '/posts',
    query: z.object({
      skip: z.number(),
      take: z.number(),
    }), // <-- Zod schema
    responses: {
      200: c.type<Post[]>(), // <-- OR normal TS types
    },
    headers: z.object({
      'x-pagination-page': z.coerce.number().optional(),
    }),
  },
});

Fulfill the contract on your server, with a type-safe router:

const router = s.router(contract, {
  getPosts: async ({ params: { id } }) => {
    return {
      status: 200,
      body: prisma.post.findUnique({ where: { id } }),
    };
  },
});

Consume the api on the client with a RPC-like interface:

const result = await client.getPosts({
  headers: { 'x-pagination-page': 1 },
  query: { skip: 0, take: 10 },
  // ^-- Fully typed!
});

Quickstart

Create a contract, implement it on your server then consume it in your client. Incrementally adopt, trial it with your team, then get shipping faster.

Contributors ✨

MASSIVE Thanks to all of these wonderful people (emoji key), who have helped make ts-rest possible:

Star History

Since our first commit in 2022 we've been growing steadily. We're proud of our progress and we're excited about the future.

3.45.2

2 days ago

3.45.1

4 days ago

3.45.0

11 days ago

3.45.0-beta.0

11 days ago

3.45.0-beta.1

11 days ago

3.44.1

18 days ago

3.44.0

20 days ago

3.43.0

22 days ago

3.42.0

23 days ago

3.41.2

27 days ago

3.41.1

29 days ago

3.41.0

1 month ago

3.40.1

1 month ago

3.40.0

1 month ago

3.39.2

1 month ago

3.39.0

1 month ago

3.39.1

1 month ago

3.38.0

1 month ago

3.37.0

1 month ago

3.36.0

2 months ago

3.35.0

2 months ago

3.36.0-beta.0

2 months ago

3.35.1

2 months ago

3.34.0

2 months ago

3.33.1

2 months ago

3.33.0

4 months ago

3.32.0

4 months ago

3.31.0

4 months ago

3.28.0

9 months ago

3.26.4

10 months ago

3.30.0

8 months ago

3.30.1

8 months ago

3.30.2

8 months ago

3.30.3

7 months ago

3.30.4

7 months ago

3.30.5

6 months ago

3.27.0

9 months ago

3.26.0

11 months ago

3.26.2

11 months ago

3.26.1

11 months ago

3.26.3

11 months ago

3.27.0-rc.0

11 months ago

3.20.0

12 months ago

3.22.0

11 months ago

3.21.1

11 months ago

3.21.0

11 months ago

3.24.0

11 months ago

3.23.0

11 months ago

3.21.2

11 months ago

3.24.0-rc.0

11 months ago

3.19.4

12 months ago

3.19.5

12 months ago

3.26.0-rc3.0

11 months ago

3.22.1-pre.0

11 months ago

3.24.1-pre.0

11 months ago

3.24.1-pre.1

11 months ago

3.23.0-beta.0

11 months ago

3.26.0-rc.0

11 months ago

3.25.1

11 months ago

3.25.0

11 months ago

3.19.3

1 year ago

3.19.2

1 year ago

3.19.0

1 year ago

3.19.1

1 year ago

3.18.1

1 year ago

3.18.0

1 year ago

3.17.0

1 year ago

3.16.1

1 year ago

3.16.0

1 year ago

3.16.2

1 year ago

3.11.0

1 year ago

3.10.1

1 year ago

3.8.0

1 year ago

3.10.0

1 year ago

3.13.0

1 year ago

3.12.1

1 year ago

3.11.2

1 year ago

3.12.0

1 year ago

3.11.1

1 year ago

3.10.2

1 year ago

3.15.0

1 year ago

3.14.0

1 year ago

3.13.1

1 year ago

3.9.0

1 year ago

3.7.0

1 year ago

3.6.1

1 year ago

3.6.0

2 years ago

3.5.0

2 years ago