Sitemap
Dr. Zainal Abdul Kahar

Dr. Zainal Abdul Kahar

Senior Lecturer: Universiti Putra Malaysia Director: Game Taiko Sdn. Bhd. Director: Media Niaga

GitHub Codespace & Serverless Backend

6 min readApr 30, 2026
Press enter or click to view image in full size

Developing and deploying serverless backends using GitHub Codespaces provides a cloud-hosted, pre-configured environment that eliminates local setup overhead. More importantly, having a backend is essential for handling critical aspects such as security, authentication, and data protection.

A frontend-only application exposes sensitive logic and API keys to users, making it vulnerable to misuse and attacks. By introducing a backend, you can securely manage requests, validate user input, protect credentials, and enforce access control. This separation ensures that sensitive operations — such as database access, authentication, and business logic — are handled in a controlled and secure environment rather than being exposed in the client-side code.

Let’s Begin

  1. Log in to your GitHub account and create a new repository.
Click “new” button

2. Enter a name for your repository, then click “Create repository.”

Press enter or click to view image in full size

3. Create a README.md file to initialize the project and make the “Code” button visible.

Press enter or click to view image in full size
Click the “creating a new file”
Press enter or click to view image in full size
Name it README.md, type any text
Press enter or click to view image in full size
Click the “commit changes”

4. After the commit is complete, the “Code” button will appear. Click the “Code” button to proceed.

Press enter or click to view image in full size

5. A Codespaces popup will appear. Click “Create codespace on main” to proceed.

6. Your Codespace will open as an online Visual Studio Code (VS Code) IDE, allowing you to write, edit, and run your code directly in the browser.

Press enter or click to view image in full size

7. Next, we will install React JS, Tailwind CSS, and DaisyUI.

In the Terminal view, run the following command to create a new Vite project:

npm create vite@latest my-project

Then follow the prompts:

  • Select React
  • Choose JavaScript
  • Select Install with npm (press Enter)

This will set up your React project.

Press enter or click to view image in full size

8. Vite will start a development server so you can preview your app, and a new port will be opened automatically.

Get Dr. Zainal Abdul Kahar’s stories in your inbox

Join Medium for free to get updates from this writer.

Go to the Ports view (labeled “1”), where you will see a newly assigned port. In this example, it is 5173, though the number may vary. Click on the forwarded address (e.g., https://<random-text>...) to open and view your application output.

Press enter or click to view image in full size

9. The link will open your React JS application powered by Vite, as shown below. Any changes you make to the code will be automatically reflected on this page in real time.

Press enter or click to view image in full size

10. In the CSM3401 Codespace, you will see a folder named my-project that has been created.

11. To install Tailwind CSS, first open a new Terminal. Then, change the directory to your project folder (my-project) before running the installation commands.

Press enter or click to view image in full size
Click this icon to open new Terminal

12. Type “cd my-project” to change the directory to the react js project

Press enter or click to view image in full size

13. In the my-project directory, run the following command in the Terminal and press Enter to install the required packages:

npm install tailwindcss @tailwindcss/vite
Press enter or click to view image in full size

13. After that, locate the vite.config.js file and add the Tailwind CSS import along with the tailwindcss() plugin as shown below:

Press enter or click to view image in full size

14. Next, we need to install DaisyUI. Open the Terminal, then run the following command:

npm i -D daisyui@latest
Press enter or click to view image in full size

15. Locate the App.css file and add the following lines at the very beginning of the file:

@import "tailwindcss";
@plugin "daisyui";
Press enter or click to view image in full size

16. If an error occurs, locate the daisyui.css file in the following path: my-project → node_modules → daisyui.css. Rename it to daisyuibackup.css, then refresh the page—the error should disappear.

Press enter or click to view image in full size
Error due to Daisyui package
Press enter or click to view image in full size
Rename daisyui.css to daisyuibackup.css

17. We have completed setting up React JS, Tailwind CSS, and DaisyUI in Codespaces. Now, to prepare the backend, proceed to the Google Cloud Console.

Press enter or click to view image in full size
open https://console.cloud.google.com

18. Create a new project, then navigate to and select Cloud Run from the available services.

Press enter or click to view image in full size

19. Once opened, you will be presented with several runtime options. Select Node.js as your development environment.

Press enter or click to view image in full size

20. Enter a suitable service name, then choose the asia-southeast region for deployment.

Press enter or click to view image in full size

21. Make the service publicly accessible by selecting “Allow public access.”

Press enter or click to view image in full size

22. Click “Create” to start the server.

Press enter or click to view image in full size

22. Once the environment is created, you will see your source code workspace. You can now begin developing your backend from here.

In the functions.http file, add the following line to enable CORS:

res.set("Access-Control-Allow-Origin", "*");
Press enter or click to view image in full size

23. Copy the link to be used at the codespace

Press enter or click to view image in full size

24. Go back to your Codespace and locate the App.jsx file in the following directory: my-project → src → App.jsx.

Press enter or click to view image in full size

25. Replace the contents of App.jsx with the following code. In the fetch section, make sure to update the URL with the endpoint you generated from Cloud Run.

import { useEffect, useState } from "react";

function App() {
const [data, setData] = useState("");

useEffect(() => {
async function fetchData() {
try {
const res = await fetch(
"https://csm3401-759274578379.asia-southeast2.run.app"
);
const text = await res.text();
console.log(text);
setData(text);
} catch (err) {
console.error(err);
}
}

fetchData();
}, []);

return (
<div>
<h1>Backend Response:</h1>
<div>{data}</div>
</div>
);
}

export default App;

26. Refresh the output URL, and you should see the React JS web app successfully call Cloud Run and display the message.

Press enter or click to view image in full size

We have now completed the process of creating a React JS web application using Codespaces, without requiring you to set up any development environment on your local computer. This approach allows you to start building and running your application directly in the cloud, making the setup much faster and more convenient. It also means you are not limited to a desktop or laptop — you can easily work from devices such as tablets or other portable devices, as long as you have a browser and internet connection.

--

--

Dr. Zainal Abdul Kahar
Dr. Zainal Abdul Kahar

Written by Dr. Zainal Abdul Kahar

Senior Lecturer: Universiti Putra Malaysia Director: Game Taiko Sdn. Bhd. Director: Media Niaga