{"id":24152082,"url":"https://github.com/diedemiguel/server-actions-nextjs","last_synced_at":"2026-06-09T19:31:43.745Z","repository":{"id":236676922,"uuid":"792948029","full_name":"dieDeMiguel/server-actions-nextjs","owner":"dieDeMiguel","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-08T07:32:15.000Z","size":207,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T19:16:36.745Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dieDeMiguel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-28T02:11:23.000Z","updated_at":"2024-05-08T07:32:19.000Z","dependencies_parsed_at":"2024-05-08T08:45:44.237Z","dependency_job_id":null,"html_url":"https://github.com/dieDeMiguel/server-actions-nextjs","commit_stats":null,"previous_names":["diedemiguel/server-actions-nextjs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dieDeMiguel/server-actions-nextjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dieDeMiguel%2Fserver-actions-nextjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dieDeMiguel%2Fserver-actions-nextjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dieDeMiguel%2Fserver-actions-nextjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dieDeMiguel%2Fserver-actions-nextjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dieDeMiguel","download_url":"https://codeload.github.com/dieDeMiguel/server-actions-nextjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dieDeMiguel%2Fserver-actions-nextjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34123171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-12T10:14:58.590Z","updated_at":"2026-06-09T19:31:43.720Z","avatar_url":"https://github.com/dieDeMiguel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Asynchronous server side data fetching and mutation with NextJS.\n\nOn this learing project, the developed application uses a combination of Next.js server components, the `better-sqlite3` library, and AWS S3 to create and manage posts.\n\n1. **Next.js Server Components**: Server components in Next.js allow you to write code that runs on the server but can interact with client components. In this application, the `Posts` component is a client component that uses the `createPost` server action to create a new post. The `createPost` action receives form data, validates it, uploads an image to AWS S3, and stores the post data in a SQLite database.\n\n2. **better-sqlite3**: This is a library that provides a synchronous API for interacting with SQLite databases in Node.js. It's used in the `storePost` function in `lib/posts.js` to insert a new post into the `posts` table in the SQLite database. The `storePost` function is called by the `createPost` server action.\n\n3. **useOptimistic**: This is a custom React hook used in the `Posts` client component. It's used to optimistically update the UI when a post is liked or unliked. When the like button is clicked, the `updatePost` function is called, which first updates the local state of the posts using `updateOptimisiticPosts`, then calls the `togglePostLikeStatus` server action to update the like status in the database.\n\n4. **AWS S3**: Amazon S3 (Simple Storage Service) is a service offered by Amazon Web Services that provides object storage through a web service interface. In this application, it's used to store the images for the posts. The `uploadImage` function in `lib/aws.js` is used to upload an image to S3. This function is called by the `createPost` server action.\n\nWhen a new post is created, the `createPost` server action is called with the form data. This action validates the form data, uploads the image to AWS S3 using the `uploadImage` function, and stores the post data in the SQLite database using the `storePost` function. The URL of the uploaded image is stored in the `image_url` column of the `posts` table.\n\n## **Installation**\n\nInstall project dependencies:\n\nnpm install\n\n## **Environment Variables**\n\nTo run this project, you will need to add the following environment variables to your .env file\n\n```properties\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nAWS_S3_BUCKET=\nAWS_REGION=\n```\n\n## **Tech Stack**\n\n**Client:** React, Next.js.\n\n### **Server:** Node, \"better-sqlite3\" \\\n\n\\\nTopics Learned:\\\nuseOptimisitc, data fetching and mutation\n\n## **Authors**\n\n- [@dieDeMiguel](https://github.com/dieDeMiguel)\n\n## **License**\n\n[MIT](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiedemiguel%2Fserver-actions-nextjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiedemiguel%2Fserver-actions-nextjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiedemiguel%2Fserver-actions-nextjs/lists"}