@@ -11,6 +11,8 @@ You can use our [React hooks](/frontend/react-hooks) in your frontend applicatio
1111To create a Public Access Token, you can use the ` auth.createPublicToken ` function in your ** backend** code:
1212
1313``` tsx
14+ import { auth } from " @trigger.dev/sdk/v3" ;
15+
1416const publicToken = await auth .createPublicToken (); // 👈 this public access token has no permissions, so is pretty useless!
1517```
1618
@@ -19,6 +21,8 @@ const publicToken = await auth.createPublicToken(); // 👈 this public access t
1921By default a Public Access Token has no permissions. You must specify the scopes you need when creating a Public Access Token:
2022
2123``` ts
24+ import { auth } from " @trigger.dev/sdk/v3" ;
25+
2226const publicToken = await auth .createPublicToken ({
2327 scopes: {
2428 read: {
@@ -31,6 +35,8 @@ const publicToken = await auth.createPublicToken({
3135This will allow the token to read all runs, which is probably not what you want. You can specify only certain runs by passing an array of run IDs:
3236
3337``` ts
38+ import { auth } from " @trigger.dev/sdk/v3" ;
39+
3440const publicToken = await auth .createPublicToken ({
3541 scopes: {
3642 read: {
@@ -43,6 +49,8 @@ const publicToken = await auth.createPublicToken({
4349You can scope the token to only read certain tasks:
4450
4551``` ts
52+ import { auth } from " @trigger.dev/sdk/v3" ;
53+
4654const publicToken = await auth .createPublicToken ({
4755 scopes: {
4856 read: {
@@ -55,6 +63,8 @@ const publicToken = await auth.createPublicToken({
5563Or tags:
5664
5765``` ts
66+ import { auth } from " @trigger.dev/sdk/v3" ;
67+
5868const publicToken = await auth .createPublicToken ({
5969 scopes: {
6070 read: {
@@ -67,6 +77,8 @@ const publicToken = await auth.createPublicToken({
6777Or a specific batch of runs:
6878
6979``` ts
80+ import { auth } from " @trigger.dev/sdk/v3" ;
81+
7082const publicToken = await auth .createPublicToken ({
7183 scopes: {
7284 read: {
@@ -79,6 +91,8 @@ const publicToken = await auth.createPublicToken({
7991You can also combine scopes. For example, to read runs with specific tags and for specific tasks:
8092
8193``` ts
94+ import { auth } from " @trigger.dev/sdk/v3" ;
95+
8296const publicToken = await auth .createPublicToken ({
8397 scopes: {
8498 read: {
@@ -94,6 +108,8 @@ const publicToken = await auth.createPublicToken({
94108By default, Public Access Token's expire after 15 minutes. You can specify a different expiration time when creating a Public Access Token:
95109
96110``` ts
111+ import { auth } from " @trigger.dev/sdk/v3" ;
112+
97113const publicToken = await auth .createPublicToken ({
98114 expirationTime: " 1hr" ,
99115});
@@ -120,6 +136,8 @@ console.log(handle.publicAccessToken);
120136By default, tokens returned from the ` trigger ` function expire after 15 minutes and have a read scope for that specific run. You can customize the expiration of the auto-generated tokens by passing a ` publicTokenOptions ` object to the ` trigger ` function:
121137
122138``` ts
139+ import { tasks } from " @trigger.dev/sdk/v3" ;
140+
123141const handle = await tasks .trigger (
124142 " my-task" ,
125143 { some: " data" },
0 commit comments