{"id":25805681,"url":"https://github.com/scriptogre/platform-astro","last_synced_at":"2026-05-14T06:36:06.268Z","repository":{"id":215778968,"uuid":"724594188","full_name":"scriptogre/platform-astro","owner":"scriptogre","description":"Created with StackBlitz ⚡️","archived":false,"fork":false,"pushed_at":"2024-02-19T17:23:07.000Z","size":1126,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-01T05:53:23.107Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/github-zubgp9-c5gwat","language":"Astro","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/scriptogre.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":"2023-11-28T12:00:16.000Z","updated_at":"2024-03-13T09:00:39.000Z","dependencies_parsed_at":"2024-01-22T16:01:41.701Z","dependency_job_id":"c3e83308-0744-4992-90f6-64a1facdd32b","html_url":"https://github.com/scriptogre/platform-astro","commit_stats":null,"previous_names":["scriptogre/platform-astro"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/scriptogre/platform-astro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptogre%2Fplatform-astro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptogre%2Fplatform-astro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptogre%2Fplatform-astro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptogre%2Fplatform-astro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scriptogre","download_url":"https://codeload.github.com/scriptogre/platform-astro/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptogre%2Fplatform-astro/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33013287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"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-02-27T19:39:16.678Z","updated_at":"2026-05-14T06:36:06.250Z","avatar_url":"https://github.com/scriptogre.png","language":"Astro","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Authentication\n\n### Overview\nWe chose htmx. Unlike client-side frameworks, it handles everything server-side.\n\n### Benefits\nIt aligns with Astro's philosophy:\n- **Server-first**: Moves expensive rendering off of your visitors’ devices.\n- **Zero JS, by default**: Less client-side JavaScript to slow your site down.\n\nWe use htmx to eliminate client-side data fetching and JavaScript-dependent DOM manipulation, fully leveraging Astro's Static Site Generation (SSG). This integration allows for dynamic content without the heavy use of client-side JavaScript, except for the lightweight htmx ([~14k min.gz’d](https://unpkg.com/htmx.org/dist/)).\n\n### Examples\n\n#### Displaying User Profile Picture or Login Button\n1. Inside our top navigation bar, we include a div with the following attributes:\n    ```html\n    \u003cdiv hx-get=\"/user_or_login/\" hx-trigger=\"load\"\u003e\u003c/div\u003e\n    ```\n    - `hx-get=\"/user_or_login/\"` indicates the AJAX call to the server-side rendered (SSR) partial page found at `/src/pages/user_or_login.astro`.\n    - `hx-trigger=\"load\"` indicates that the AJAX call is made when the page loads.\n\n2. We mark the page at `/src/pages/user_or_login.astro` with `export const prerender = false`, indicating to Astro that it is suitable for SSR.\n\n3. We check the user's authentication status in `user_or_login.astro`, and render the appropriate content.\n   - Logged-in User: If the user is authenticated, it retrieves the user's profile picture.\n   - Not Logged-in: For unauthenticated users, it displays the login button.\n\n4. The request returns the complete HTML, already populated with the user's profile picture or login button, which replaces the div in the top navigation bar.\n5. We use [CSS animations](https://htmx.org/examples/animations/) or [View Transitions](https://htmx.org/essays/view-transitions/) to make this change more visually appealing.\n\nReferences:\n- [Astro Server-Side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)\n- [hx-get](https://htmx.org/attributes/hx-get/)\n- [hx-trigger](https://htmx.org/attributes/hx-trigger/)\n- [Related Discussion on Reddit](https://www.reddit.com/r/htmx/comments/15g6weg/composing_with_hxtriggerload_and_hxget_is_it_a/)\n\n#### Logging In\n1. If the user was not authenticated, the login button is displayed:\n    ```html\n   \u003cLoginButton hx-get=\"/auth/login/\"\n                hx-target=\"body\"\n                hx-swap=\"beforeend\" /\u003e\n    ```\n    - The page at `/src/pages/auth/login.astro` is a partial (not a whole page) which only includes a `\u003cModal\u003e` component with the login form.\n    - `hx-get=\"/auth/login/\"` indicates the AJAX call to the SSR partial page found at `/src/pages/auth/signin.astro`.\n    - `hx-target=\"body\"` and `hx-swap=\"beforeend\"` indicate that the response should be appended to the end of the body.\n\n2. The user enters their credentials and submits the form.\n3. The request returns the complete HTML, already populated with the user's profile picture or login button, which replaces the div in the top navigation bar.\n\n## Notes\n- This projects always has `trailingSlash: \"always\"` in `astro.config.mjs`. Ensure you include them, otherwise you'll get 404.\n\n*This is because of an issue where `Astro.url.pathname` was inconsistent between dev and build, which caused issues in `\u003cSideNav\u003e` component. https://github.com/withastro/astro/issues/4638*\n\n- Inside HTMX partial pages that are SSR, the typical `redirect()` function does not work. \n  - Instead, use the `redirectWithHtmx()` function, which uses `HX-Redirect` header to do a full page client redirect. \n  - For more information, see https://htmx.org/reference/#response_headers\n\n- Most of the auth logic has been moved into `auth.ts`. \n  - This might cause some abstractions seeming redundant, but this choice was to keep the code consistent and organized. \n  - This also enables easily swapping the auth logic with a different provider (e.g. Auth0), without having to modify the `.astro` files too much.\n  - What the `.astro` files do is to call functions from `auth.ts`, handle redirects and display the appropriate content / error messages.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptogre%2Fplatform-astro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptogre%2Fplatform-astro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptogre%2Fplatform-astro/lists"}