@tanstack/cta-framework-react-cra 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ ## Setting up Strapi
2
+
3
+ The current setup shows an example of how to use Strapi with an articles collection which is part of the example structure & data.
4
+
5
+ - Create a local running copy of the strapi admin
6
+
7
+ ```bash
8
+ pnpx create-strapi@latest my-strapi-project
9
+ cd my-strapi-project
10
+ pnpm dev
11
+ ```
12
+
13
+ - Login and publish the example articles to see them on the strapi demo page.
14
+ - Set the `VITE_STRAPI_URL` environment variable in your `.env.local`. (For local it should be http://localhost:1337/api)
@@ -0,0 +1,2 @@
1
+ # Strapi configuration
2
+ VITE_STRAPI_URL="http://localhost:1337/api"
@@ -0,0 +1,7 @@
1
+ import { strapi } from "@strapi/client";
2
+
3
+ export const strapiClient = strapi({
4
+ baseURL: import.meta.env.VITE_STRAPI_URL,
5
+ });
6
+
7
+ export const articles = strapiClient.collection("articles");
@@ -0,0 +1,66 @@
1
+ import { articles } from '@/lib/strapiClient'
2
+ import { createFileRoute, Link } from '@tanstack/react-router'
3
+
4
+ export const Route = createFileRoute('/demo/strapi')({
5
+ component: RouteComponent,
6
+ loader: async () => {
7
+ const { data: strapiArticles } = await articles.find()
8
+ return strapiArticles
9
+ },
10
+ })
11
+
12
+ function RouteComponent() {
13
+ const strapiArticles = Route.useLoaderData()
14
+
15
+ return (
16
+ <div className="min-h-screen bg-gradient-to-b from-slate-900 via-slate-800 to-slate-900 p-8">
17
+ <div className="max-w-7xl mx-auto">
18
+ <h1 className="text-4xl font-bold mb-8 text-white">
19
+ <span className="bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent">
20
+ Strapi
21
+ </span>{' '}
22
+ <span className="text-gray-300">Articles</span>
23
+ </h1>
24
+
25
+ {strapiArticles && strapiArticles.length > 0 ? (
26
+ <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
27
+ {strapiArticles.map((article) => (
28
+ <Link
29
+ key={article.id}
30
+ to="/demo/strapi/$articleId"
31
+ params={{ articleId: article.documentId }}
32
+ className="block"
33
+ >
34
+ <article className="bg-slate-800/50 backdrop-blur-sm border border-slate-700 rounded-xl p-6 hover:border-cyan-500/50 transition-all duration-300 hover:shadow-lg hover:shadow-cyan-500/10 cursor-pointer h-full">
35
+ <h2 className="text-xl font-semibold text-white mb-3">
36
+ {article.title || 'Untitled'}
37
+ </h2>
38
+
39
+ {article.description && (
40
+ <p className="text-gray-400 mb-4 leading-relaxed">
41
+ {article.description}
42
+ </p>
43
+ )}
44
+
45
+ {article.content && (
46
+ <p className="text-gray-400 line-clamp-3 leading-relaxed">
47
+ {article.content}
48
+ </p>
49
+ )}
50
+
51
+ {article.createdAt && (
52
+ <p className="text-sm text-cyan-400/70 mt-4">
53
+ {new Date(article.createdAt).toLocaleDateString()}
54
+ </p>
55
+ )}
56
+ </article>
57
+ </Link>
58
+ ))}
59
+ </div>
60
+ ) : (
61
+ <p className="text-gray-400">No articles found.</p>
62
+ )}
63
+ </div>
64
+ </div>
65
+ )
66
+ }
@@ -0,0 +1,78 @@
1
+ import { articles } from '@/lib/strapiClient'
2
+ import { createFileRoute, Link } from '@tanstack/react-router'
3
+
4
+ export const Route = createFileRoute('/demo/strapi_/$articleId')({
5
+ component: RouteComponent,
6
+ loader: async ({ params }) => {
7
+ const { data: article } = await articles.findOne(params.articleId)
8
+ return article
9
+ },
10
+ })
11
+
12
+ function RouteComponent() {
13
+ const article = Route.useLoaderData()
14
+
15
+ return (
16
+ <div className="min-h-screen bg-gradient-to-b from-slate-900 via-slate-800 to-slate-900 p-8">
17
+ <div className="max-w-4xl mx-auto">
18
+ <Link
19
+ to="/demo/strapi"
20
+ className="inline-flex items-center text-cyan-400 hover:text-cyan-300 mb-6 transition-colors"
21
+ >
22
+ <svg
23
+ xmlns="http://www.w3.org/2000/svg"
24
+ className="h-5 w-5 mr-2"
25
+ viewBox="0 0 20 20"
26
+ fill="currentColor"
27
+ >
28
+ <path
29
+ fillRule="evenodd"
30
+ d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z"
31
+ clipRule="evenodd"
32
+ />
33
+ </svg>
34
+ Back to Articles
35
+ </Link>
36
+
37
+ <article className="bg-slate-800/50 backdrop-blur-sm border border-slate-700 rounded-xl p-8">
38
+ <h1 className="text-4xl font-bold text-white mb-4">
39
+ {article?.title || 'Untitled'}
40
+ </h1>
41
+
42
+ {article?.createdAt && (
43
+ <p className="text-sm text-cyan-400/70 mb-6">
44
+ Published on{' '}
45
+ {new Date(article?.createdAt).toLocaleDateString('en-US', {
46
+ year: 'numeric',
47
+ month: 'long',
48
+ day: 'numeric',
49
+ })}
50
+ </p>
51
+ )}
52
+
53
+ {article?.description && (
54
+ <div className="mb-6">
55
+ <h2 className="text-xl font-semibold text-gray-300 mb-3">
56
+ Description
57
+ </h2>
58
+ <p className="text-gray-400 leading-relaxed">
59
+ {article?.description}
60
+ </p>
61
+ </div>
62
+ )}
63
+
64
+ {article?.content && (
65
+ <div>
66
+ <h2 className="text-xl font-semibold text-gray-300 mb-3">
67
+ Content
68
+ </h2>
69
+ <div className="text-gray-400 leading-relaxed whitespace-pre-wrap">
70
+ {article?.content}
71
+ </div>
72
+ </div>
73
+ )}
74
+ </article>
75
+ </div>
76
+ </div>
77
+ )
78
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "Strapi",
3
+ "description": "Use the Strapi CMS to manage your content.",
4
+ "link": "https://strapi.io/",
5
+ "phase": "add-on",
6
+ "type": "add-on",
7
+ "modes": [
8
+ "file-router"
9
+ ],
10
+ "routes": [
11
+ {
12
+ "url": "/demo/strapi",
13
+ "name": "Strapi",
14
+ "path": "src/routes/demo.strapi.tsx",
15
+ "jsName": "StrapiDemo"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "@strapi/client": "^1.5.0"
4
+ }
5
+ }
@@ -0,0 +1,8 @@
1
+ <svg width="600" height="600" viewBox="0 0 600 600" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0 208C0 109.948 0 60.9218 30.4609 30.4609C60.9218 0 109.948 0 208 0H392C490.052 0 539.078 0 569.539 30.4609C600 60.9218 600 109.948 600 208V392C600 490.052 600 539.078 569.539 569.539C539.078 600 490.052 600 392 600H208C109.948 600 60.9218 600 30.4609 569.539C0 539.078 0 490.052 0 392V208Z" fill="#4945FF"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M414 182H212V285H315V388H418V186C418 183.791 416.209 182 414 182Z" fill="white"/>
4
+ <rect x="311" y="285" width="4" height="4" fill="white"/>
5
+ <path d="M212 285H311C313.209 285 315 286.791 315 289V388H216C213.791 388 212 386.209 212 384V285Z" fill="#9593FF"/>
6
+ <path d="M315 388H418L318.414 487.586C317.154 488.846 315 487.953 315 486.172V388Z" fill="#9593FF"/>
7
+ <path d="M212 285H113.828C112.046 285 111.154 282.846 112.414 281.586L212 182V285Z" fill="#9593FF"/>
8
+ </svg>
@@ -0,0 +1,3 @@
1
+ ## Setting up WorkOS
2
+
3
+ - Set the `VITE_WORKOS_CLIENT_ID` in your `.env.local`.
@@ -0,0 +1,4 @@
1
+ VITE_WORKOS_CLIENT_ID=
2
+
3
+ # This should be your Custom Authentication Domain in production
4
+ VITE_WORKOS_API_HOSTNAME=api.workos.com
@@ -0,0 +1,41 @@
1
+ import { useAuth } from '@workos-inc/authkit-react'
2
+
3
+ export default function SignInButton({ large }: { large?: boolean }) {
4
+ const { user, isLoading, signIn, signOut } = useAuth()
5
+
6
+ const buttonClasses = `${
7
+ large ? 'px-6 py-3 text-base' : 'px-4 py-2 text-sm'
8
+ } bg-blue-600 hover:bg-blue-700 text-white font-medium rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed`
9
+
10
+ if (user) {
11
+ return (
12
+ <div className="flex flex-col gap-3">
13
+ <div className="flex items-center gap-2">
14
+ {user.profilePictureUrl && (
15
+ <img
16
+ src={user.profilePictureUrl}
17
+ alt={`Avatar of ${user.firstName} ${user.lastName}`}
18
+ className="w-10 h-10 rounded-full"
19
+ />
20
+ )}
21
+ {user.firstName} {user.lastName}
22
+ </div>
23
+ <button onClick={() => signOut()} className={buttonClasses}>
24
+ Sign Out
25
+ </button>
26
+ </div>
27
+ )
28
+ }
29
+
30
+ return (
31
+ <button
32
+ onClick={() => {
33
+ signIn()
34
+ }}
35
+ className={buttonClasses}
36
+ disabled={isLoading}
37
+ >
38
+ Sign In {large && 'with AuthKit'}
39
+ </button>
40
+ )
41
+ }
@@ -0,0 +1,23 @@
1
+ import { useEffect } from "react";
2
+ import { useAuth } from "@workos-inc/authkit-react";
3
+ import { useLocation } from "@tanstack/react-router";
4
+
5
+ type UserOrNull = ReturnType<typeof useAuth>["user"];
6
+
7
+ // redirects to the sign-in page if the user is not signed in
8
+ export const useUser = (): UserOrNull => {
9
+ const { user, isLoading, signIn } = useAuth();
10
+ const location = useLocation();
11
+
12
+ useEffect(() => {
13
+ if (!isLoading && !user) {
14
+ signIn({
15
+ state: { returnTo: location.pathname },
16
+ });
17
+ } else {
18
+ console.log(user);
19
+ }
20
+ }, [isLoading, user]);
21
+
22
+ return user;
23
+ };
@@ -0,0 +1,34 @@
1
+ import { AuthKitProvider } from '@workos-inc/authkit-react'
2
+ import { useNavigate } from '@tanstack/react-router'
3
+
4
+ const VITE_WORKOS_CLIENT_ID = import.meta.env.VITE_WORKOS_CLIENT_ID
5
+ if (!VITE_WORKOS_CLIENT_ID) {
6
+ throw new Error('Add your WorkOS Client ID to the .env.local file')
7
+ }
8
+
9
+ const VITE_WORKOS_API_HOSTNAME = import.meta.env.VITE_WORKOS_API_HOSTNAME
10
+ if (!VITE_WORKOS_API_HOSTNAME) {
11
+ throw new Error('Add your WorkOS API Hostname to the .env.local file')
12
+ }
13
+
14
+ export default function AppWorkOSProvider({
15
+ children,
16
+ }: {
17
+ children: React.ReactNode
18
+ }) {
19
+ const navigate = useNavigate()
20
+
21
+ return (
22
+ <AuthKitProvider
23
+ clientId={VITE_WORKOS_CLIENT_ID}
24
+ apiHostname={VITE_WORKOS_API_HOSTNAME}
25
+ onRedirectCallback={({ state }) => {
26
+ if (state?.returnTo) {
27
+ navigate(state.returnTo)
28
+ }
29
+ }}
30
+ >
31
+ {children}
32
+ </AuthKitProvider>
33
+ )
34
+ }
@@ -0,0 +1,109 @@
1
+ import { createFileRoute } from '@tanstack/react-router'
2
+ import { useAuth } from '@workos-inc/authkit-react'
3
+
4
+ export const Route = createFileRoute('/demo/workos')({
5
+ ssr: false,
6
+ component: App,
7
+ })
8
+
9
+ function App() {
10
+ const { user, isLoading, signIn, signOut } = useAuth()
11
+
12
+ if (isLoading) {
13
+ return (
14
+ <div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 flex items-center justify-center p-4">
15
+ <div className="bg-gray-800/50 backdrop-blur-sm rounded-2xl shadow-2xl p-8 w-full max-w-md border border-gray-700/50">
16
+ <p className="text-gray-400 text-center">Loading...</p>
17
+ </div>
18
+ </div>
19
+ )
20
+ }
21
+
22
+ if (user) {
23
+ return (
24
+ <div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 flex items-center justify-center p-4">
25
+ <div className="bg-gray-800/50 backdrop-blur-sm rounded-2xl shadow-2xl p-8 w-full max-w-md border border-gray-700/50">
26
+ <h1 className="text-2xl font-bold text-white mb-6 text-center">
27
+ User Profile
28
+ </h1>
29
+
30
+ <div className="space-y-6">
31
+ {/* Profile Picture */}
32
+ {user.profilePictureUrl && (
33
+ <div className="flex justify-center">
34
+ <img
35
+ src={user.profilePictureUrl}
36
+ alt={`Avatar of ${user.firstName} ${user.lastName}`}
37
+ className="w-24 h-24 rounded-full border-4 border-gray-700 shadow-lg"
38
+ />
39
+ </div>
40
+ )}
41
+
42
+ {/* User Information */}
43
+ <div className="space-y-4">
44
+ <div className="bg-gray-700/30 rounded-lg p-4 border border-gray-600/30">
45
+ <label className="text-gray-400 text-sm font-medium block mb-1">
46
+ First Name
47
+ </label>
48
+ <p className="text-white text-lg">{user.firstName || 'N/A'}</p>
49
+ </div>
50
+
51
+ <div className="bg-gray-700/30 rounded-lg p-4 border border-gray-600/30">
52
+ <label className="text-gray-400 text-sm font-medium block mb-1">
53
+ Last Name
54
+ </label>
55
+ <p className="text-white text-lg">{user.lastName || 'N/A'}</p>
56
+ </div>
57
+
58
+ <div className="bg-gray-700/30 rounded-lg p-4 border border-gray-600/30">
59
+ <label className="text-gray-400 text-sm font-medium block mb-1">
60
+ Email
61
+ </label>
62
+ <p className="text-white text-lg break-all">
63
+ {user.email || 'N/A'}
64
+ </p>
65
+ </div>
66
+
67
+ <div className="bg-gray-700/30 rounded-lg p-4 border border-gray-600/30">
68
+ <label className="text-gray-400 text-sm font-medium block mb-1">
69
+ User ID
70
+ </label>
71
+ <p className="text-gray-300 text-sm font-mono break-all">
72
+ {user.id || 'N/A'}
73
+ </p>
74
+ </div>
75
+ </div>
76
+
77
+ {/* Sign Out Button */}
78
+ <button
79
+ onClick={() => signOut()}
80
+ className="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg transition-colors shadow-lg hover:shadow-xl"
81
+ >
82
+ Sign Out
83
+ </button>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ )
88
+ }
89
+
90
+ return (
91
+ <div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 flex items-center justify-center p-4">
92
+ <div className="bg-gray-800/50 backdrop-blur-sm rounded-2xl shadow-2xl p-8 w-full max-w-md border border-gray-700/50">
93
+ <h1 className="text-2xl font-bold text-white mb-6 text-center">
94
+ WorkOS Authentication
95
+ </h1>
96
+ <p className="text-gray-400 text-center mb-6">
97
+ Sign in to view your profile information
98
+ </p>
99
+ <button
100
+ onClick={() => signIn()}
101
+ disabled={isLoading}
102
+ className="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg transition-colors shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed"
103
+ >
104
+ Sign In with AuthKit
105
+ </button>
106
+ </div>
107
+ </div>
108
+ )
109
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "WorkOS",
3
+ "description": "Add WorkOS authentication to your application.",
4
+ "phase": "add-on",
5
+ "modes": ["file-router"],
6
+ "type": "add-on",
7
+ "link": "https://workos.com",
8
+ "tailwind": true,
9
+ "routes": [
10
+ {
11
+ "icon": "CircleUserRound",
12
+ "url": "/demo/workos",
13
+ "name": "WorkOS",
14
+ "path": "src/routes/demo.workos.tsx",
15
+ "jsName": "WorkOSDemo"
16
+ }
17
+ ],
18
+ "integrations": [
19
+ {
20
+ "type": "header-user",
21
+ "jsName": "WorkOSHeader",
22
+ "path": "src/components/workos-user.tsx"
23
+ },
24
+ {
25
+ "type": "provider",
26
+ "jsName": "WorkOSProvider",
27
+ "path": "src/integrations/workos/provider.tsx"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": {
3
+ "@workos-inc/authkit-react": "^0.13.0",
4
+ "zod": "^4.1.11"
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <ellipse cx="16.0003" cy="16" rx="4.99998" ry="5" fill="#9785FF" style="fill:#9785FF;fill:color(display-p3 0.5922 0.5216 1.0000);fill-opacity:1;"/>
3
+ <path d="M25.0091 27.8382C25.4345 28.2636 25.3918 28.9679 24.8919 29.3027C22.3488 31.0062 19.2899 31.9997 15.9991 31.9997C12.7082 31.9997 9.64935 31.0062 7.10616 29.3027C6.60633 28.9679 6.56361 28.2636 6.98901 27.8382L10.6429 24.1843C10.9732 23.854 11.4855 23.8019 11.9012 24.0148C13.1303 24.6445 14.5232 24.9997 15.9991 24.9997C17.4749 24.9997 18.8678 24.6445 20.0969 24.0148C20.5126 23.8019 21.0249 23.854 21.3552 24.1843L25.0091 27.8382Z" fill="#9785FF" style="fill:#9785FF;fill:color(display-p3 0.5922 0.5216 1.0000);fill-opacity:1;"/>
4
+ <path opacity="0.6" d="M24.8928 2.697C25.3926 3.0318 25.4353 3.73609 25.0099 4.16149L21.356 7.81544C21.0258 8.14569 20.5134 8.19785 20.0978 7.98491C18.8687 7.35525 17.4758 7 15.9999 7C11.0294 7 6.99997 11.0294 6.99997 16C6.99997 17.4759 7.35522 18.8688 7.98488 20.0979C8.19782 20.5136 8.14565 21.0259 7.81541 21.3561L4.16147 25.0101C3.73607 25.4355 3.03178 25.3927 2.69698 24.8929C0.993522 22.3497 0 19.2909 0 16C0 7.16344 7.16341 0 15.9999 0C19.2908 0 22.3496 0.993529 24.8928 2.697Z" fill="#9785FF" style="fill:#9785FF;fill:color(display-p3 0.5922 0.5216 1.0000);fill-opacity:1;"/>
5
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/cta-framework-react-cra",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "description": "CTA Framework for React (Create React App)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "author": "Jack Herrington <jherr@pobox.com>",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@tanstack/cta-engine": "0.27.1"
26
+ "@tanstack/cta-engine": "0.28.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^24.6.0",