You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Reference documentation for API connections
4
+
---
5
+
6
+
This generator is used to connect projects to APIs. Simply select the source project (the project that will call your API) and target project (your API project), and this generator will handle integrating the two.
7
+
8
+
## Connecting an API
9
+
10
+
You can connect a source and target project in two ways:
11
+
12
+
### 1. Using VSCode IDE
13
+
14
+
First, install the NX Console extension for VSCode:
You can connect a React website to a tRPC API. For details, please refer to the [API connection section of the tRPC reference documentation](/reference/trpc/#api-connection-trpc-react).
Copy file name to clipboardExpand all lines: docs/src/content/docs/reference/trpc.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,16 @@ description: Reference documentation for tRPC
7
7
8
8
The AWS Plugin for Nx makes building APIs with tRPC on AWS easy by providing two main generators:
9
9
10
-
-[`trpc#backend`](#trpc-backend) - Generates the backend code to implement a tRPC API as well as infrastructure to deploy it with API Gateway
11
-
-[`trpc#react`](#trpc-react) - Integrates a tRPC API with a React website
10
+
-[`ts#trpc-api`](#trpc-api) - Generates the backend code to implement a tRPC API as well as infrastructure to deploy it with API Gateway
11
+
-[`api-connection`](#api-connection-trpc-react) - Supports integrating a tRPC API with a React website
12
12
13
-
## tRPC Backend
13
+
## tRPC API
14
14
15
-
The tRPC Backend generator creates a new tRPC API with AWS CDK infrastructure setup. The generated backend uses AWS Lambda for serverless deployment and includes schema validation using [Zod](https://zod.dev/). It sets up [AWS Lambda Powertools](https://docs.powertools.aws.dev/lambda/typescript/latest/) for observability, including logging, AWS X-Ray tracing and Cloudwatch Metrics.
15
+
The tRPC API generator creates a new tRPC API with AWS CDK infrastructure setup. The generated backend uses AWS Lambda for serverless deployment and includes schema validation using [Zod](https://zod.dev/). It sets up [AWS Lambda Powertools](https://docs.powertools.aws.dev/lambda/typescript/latest/) for observability, including logging, AWS X-Ray tracing and Cloudwatch Metrics.
16
16
17
-
### Generating a new tRPC Backend
17
+
### Generating a new tRPC API
18
18
19
-
You can generate a new tRPC backend in two ways:
19
+
You can generate a new tRPC API in two ways:
20
20
21
21
#### 1. Using VSCode IDE
22
22
@@ -31,7 +31,7 @@ Then generate your API:
31
31
32
32
1. Open the NX Console in VSCode
33
33
2. Click on "Generate"
34
-
3. Search for "trpc#backend"
34
+
3. Search for "ts#trpc-api"
35
35
4. Fill in the required parameters in the form
36
36
5. Click "Run"
37
37
@@ -40,13 +40,13 @@ Then generate your API:
40
40
Generate the API:
41
41
42
42
```bash
43
-
nx g @aws/nx-plugin:trpc#backend my-api --directory=apps/api
43
+
nx g @aws/nx-plugin:ts#trpc-api my-api --directory=apps/api
44
44
```
45
45
46
46
You can also perform a dry-run to see what files would be generated without actually creating them:
47
47
48
48
```bash
49
-
nx g @aws/nx-plugin:trpc#backend my-api --directory=apps/api --dry-run
49
+
nx g @aws/nx-plugin:ts#trpc-api my-api --directory=apps/api --dry-run
50
50
```
51
51
52
52
Both methods will create a new tRPC backend API in the specified directory with all the necessary configuration and infrastructure code.
If you are calling your API from a React website, consider using the [tRPC React](#trpc-react) generator to configure the client.
398
+
If you are calling your API from a React website, consider using the [API Connection](#api-connection-trpc-react) generator to configure the client.
399
399
400
-
## tRPC React
400
+
## API Connection: tRPC React
401
401
402
402
AWS Plugin for Nx provides a generator to quickly integrate your tRPC API with a React website. It sets up all necessary configuration for connecting to your tRPC backends, including AWS IAM authentication support and proper error handling. The integration provides full end-to-end type safety between your frontend and tRPC backend(s).
403
403
@@ -441,7 +441,7 @@ Then add tRPC to your React application:
441
441
442
442
1. Open the NX Console in VSCode
443
443
2. Click on "Generate"
444
-
3. Search for "trpc#react"
444
+
3. Search for "api-connection"
445
445
4. Fill in the required parameters in the form
446
446
5. Click "Run"
447
447
@@ -450,24 +450,24 @@ Then add tRPC to your React application:
450
450
Add tRPC to your React application:
451
451
452
452
```bash
453
-
nx g @aws/nx-plugin:trpc#react --frontendProjectName=my-app --backendProjectName=my-api --auth=IAM
453
+
nx g @aws/nx-plugin:api-connection --sourceProject=my-app --targetProject=my-api --auth=IAM
454
454
```
455
455
456
456
You can also perform a dry-run to see what files would be generated without actually creating them:
457
457
458
458
```bash
459
-
nx g @aws/nx-plugin:trpc#react --frontendProjectName=my-app --backendProjectName=my-api --auth=IAM --dry-run
459
+
nx g @aws/nx-plugin:api-connection --sourceProject=my-app --targetProject=my-api --auth=IAM --dry-run
460
460
```
461
461
462
462
Both methods will add tRPC client integration to your React application with all the necessary configuration.
0 commit comments