<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Touhidul Islam Chayan</title>
    <description>The latest articles on DEV Community by Touhidul Islam Chayan (@chnspart).</description>
    <link>https://dev.to/chnspart</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F624683%2F57759ee4-9203-4d45-b539-58a9b0fb5399.png</url>
      <title>DEV Community: Touhidul Islam Chayan</title>
      <link>https://dev.to/chnspart</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chnspart"/>
    <language>en</language>
    <item>
      <title>Revolutionizing TypeScript Development: How Create-T3-App Streamlines Backend-Frontend Integration (Clerk)</title>
      <dc:creator>Touhidul Islam Chayan</dc:creator>
      <pubDate>Thu, 04 May 2023 04:24:27 +0000</pubDate>
      <link>https://dev.to/chnspart/revolutionizing-typescript-development-how-create-t3-app-streamlines-backend-frontend-integration-p60</link>
      <guid>https://dev.to/chnspart/revolutionizing-typescript-development-how-create-t3-app-streamlines-backend-frontend-integration-p60</guid>
      <description>&lt;p&gt;With the advent of TypeScript, web development has become more efficient, reliable, and scalable. However, setting up a TypeScript project from scratch can be daunting and time-consuming. That's where Create-T3-App comes in - a new tool that streamlines the process of creating TypeScript applications and makes backend-frontend integration much faster and easier.&lt;/p&gt;

&lt;p&gt;In this blog post, we'll discuss how to start using Create-T3-App and why it's better and beneficial.&lt;/p&gt;

&lt;p&gt;Getting Started with Create-T3-App&lt;br&gt;
To get started with Create-T3-App, you need to have Node.js and npm installed on your machine. Once you have them installed, open up your terminal and type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; create-t3-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you can create a new project with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;create-t3-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a folder called my-app with the following structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-app
├── client
│ ├── public
│ ├── src
│ └── package.json
├── server
│ ├── src
│ └── package.json
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wk9QjEqF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y3kidjkvfbxf4fiuept.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wk9QjEqF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y3kidjkvfbxf4fiuept.png" alt="Image description" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The client folder contains the React front-end code, and the server folder contains the Express back-end code. Both are written in TypeScript and have their own package.json files with the necessary dependencies and scripts. The root package.json file allows you to run both the client and the server concurrently with one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will launch the front-end on &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt; and the back-end on &lt;a href="http://localhost:5000"&gt;http://localhost:5000&lt;/a&gt;. You can also run them separately with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run client
npm run server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The create-t3-app tool also sets up some useful features for you, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hot reloading for both the front-end and the back-end with webpack and nodemon.&lt;/li&gt;
&lt;li&gt;Linting and formatting with ESLint and Prettier.&lt;/li&gt;
&lt;li&gt;Testing with Jest and React Testing Library.&lt;/li&gt;
&lt;li&gt;Type checking with TypeScript.&lt;/li&gt;
&lt;li&gt;Proxying requests from the front-end to the back-end with http-proxy-middleware.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Create-T3-App is Better and Beneficial
&lt;/h2&gt;

&lt;p&gt;Create-T3-App is a comprehensive boilerplate that provides a solid foundation for building TypeScript applications. Here are some reasons why it's better and beneficial:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Faster Development&lt;br&gt;
Create-T3-App eliminates the need for setting up a TypeScript project from scratch, saving you a lot of time and effort. It comes with all the necessary tools and configurations needed for a TypeScript project, such as TypeScript, ESLint, Prettier, and Jest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability&lt;br&gt;
Create-T3-App provides a scalable architecture that separates the frontend and backend into separate folders. This separation allows for easier maintenance and scalability of the application as it grows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved Backend-Frontend Integration&lt;br&gt;
One of the biggest benefits of Create-T3-App is its ability to streamline the integration between the backend and frontend. The backend is built using Node.js and Express, while the frontend is built using React. The two are connected using a proxy configuration in the package.json file, which enables requests from the frontend to be proxied to the backend. This configuration eliminates the need for CORS handling and makes backend-frontend integration much faster and easier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Typescript Support&lt;br&gt;
Create-T3-App is built with TypeScript, which provides strong typing and better code analysis. This ensures that your code is more reliable, efficient, and easier to maintain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With create-t3-app, you can save time and effort by having a ready-made project structure that follows best practices and supports modern web development. You can focus on writing your business logic and creating your user interface without worrying about the configuration and setup. You can also enjoy the benefits of TypeScript, such as type safety, code completion, and refactoring. If you are looking for a fast and easy way to create a full-stack TypeScript web application, give create-t3-app a try today!&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Add Clerk as a User Authentication with Create-T3-App
&lt;/h2&gt;

&lt;p&gt;Create-T3-App comes with built-in user authentication using Passport.js, but you can also integrate Clerk for a more robust and secure authentication system. Clerk provides a user authentication and identity management system that's easy to use and highly customizable.&lt;/p&gt;

&lt;p&gt;Here are the steps to add Clerk as a user authentication with Create-T3-App:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a Clerk account and project - First, create a Clerk account and a new project. Once you have your project set up, you can get your API key and API URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Clerk SDK - Next, install the Clerk SDK by running the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @clerk/clerk-sdk-node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Configure Clerk - In the &lt;code&gt;config.ts&lt;/code&gt; file, add the following code to configure Clerk:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clerk: {
  apiKey: process.env.CLERK_API_KEY!,
  apiBaseUrl: process.env.CLERK_API_BASE_URL!,
},

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to replace &lt;code&gt;process.env.CLERK_API_KEY!&lt;/code&gt; and &lt;code&gt;process.env.CLERK_API_BASE_URL!&lt;/code&gt; with your Clerk API key and API URL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Implement Clerk - In the &lt;code&gt;server.ts&lt;/code&gt; file, replace the &lt;code&gt;passport&lt;/code&gt; middleware with Clerk. Here's an example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const clerk = new Clerk({
  apiKey: config.clerk.apiKey,
  apiBaseUrl: config.clerk.apiBaseUrl,
});

app.use(clerk.middleware);

app.post('/api/auth/signout', clerk.controllers.handleSignout);

// Protect routes with Clerk
app.use('/api/*', clerk.protect({ requireVerified: true }), apiRouter);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code initializes Clerk, adds the Clerk middleware, and protects routes with Clerk. Note that the &lt;code&gt;requireVerified&lt;/code&gt;option requires users to verify their email address before they can access protected routes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update Login and Logout Routes - In the &lt;code&gt;routes/auth.ts&lt;/code&gt; file, replace the &lt;code&gt;passport.authenticate&lt;/code&gt; middleware with Clerk. Here's an example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.post('/login', clerk.controllers.signIn);
router.post('/logout', clerk.controllers.handleSignout);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code uses the Clerk &lt;code&gt;signIn&lt;/code&gt; and &lt;code&gt;handleSignout&lt;/code&gt; controllers for login and logout routes.&lt;/p&gt;

&lt;p&gt;With these steps, you can now use Clerk as a user authentication system in your Create-T3-App project. Clerk provides a robust and secure authentication system that's easy to integrate and customize.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

&lt;p&gt;👋 Hi, I’m &lt;a class="mentioned-user" href="https://dev.to/chnspart"&gt;@chnspart&lt;/a&gt;&lt;br&gt;
👀 I’m interested in Javascript&lt;br&gt;
🌱 I’m currently learning Nest.JS &amp;amp; Next.JS&lt;br&gt;
📫 How to reach me &lt;a href="mailto:imchn24@gmail.com"&gt;imchn24@gmail.com&lt;/a&gt;&lt;br&gt;
🏀 My designs Portfolios &lt;a href="https://behance.net/chnspart/"&gt;https://behance.net/chnspart/&lt;/a&gt; ※ &lt;a href="https://dribbble.com/chnspart/"&gt;https://dribbble.com/chnspart/&lt;/a&gt;&lt;br&gt;
🌐 My website &lt;a href="https://chnspart.com"&gt;https://chnspart.com&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
