{"id":19383314,"url":"https://github.com/alignable/bifrost","last_synced_at":"2025-04-23T21:31:51.290Z","repository":{"id":169099062,"uuid":"635056676","full_name":"Alignable/bifrost","owner":"Alignable","description":"Bridge to React","archived":false,"fork":false,"pushed_at":"2024-09-16T18:02:59.000Z","size":670,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-16T22:14:29.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Alignable.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-05-01T21:45:03.000Z","updated_at":"2024-09-16T18:03:04.000Z","dependencies_parsed_at":"2023-10-03T00:25:05.174Z","dependency_job_id":"79439d23-9284-4060-8f80-44d6d62c6068","html_url":"https://github.com/Alignable/bifrost","commit_stats":null,"previous_names":["alignable/bifrost"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alignable%2Fbifrost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alignable%2Fbifrost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alignable%2Fbifrost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alignable%2Fbifrost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alignable","download_url":"https://codeload.github.com/Alignable/bifrost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223934084,"owners_count":17227648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-10T09:25:29.925Z","updated_at":"2024-11-10T09:25:30.490Z","avatar_url":"https://github.com/Alignable.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"bifrost is the framework for incremental migration from Rails/Turbolinks to Vite-powered React SSR.\n\n# How does it work?\n\n1. Vike tries to handle request\n2. If it cannot, proxy to Rails\n3. If Rails returns layout, wrap in layout\n4. Else just return as-is\n\n## Breaking changes moving from turbolinks to bifrost:\n\n- turbolinks-permanent is gone\n- request:start and request:end events removed\n- Some discrepency in event data and exactly when they fire\n\n## Getting Started\n\n### Installation\n\nInstall and setup [Vike](https://vike.dev/) (don't use vike-react)\nInstall a Fastify server\nInstall `@alignable/bifrost` and `@alignable/bifrost-fastify`\n\nIn fastify, register viteProxyPlugin\nCreate your default config `renderer/+config.ts` with `extends [BifrostConfig]` and default `proxyMode: false`, which lets you build Vike-rendered pages.\n\n### Proxy modes\n\nThe \"wrapped\" proxy mode is the main point of Bifrost. The backend proxies your request to Rails and wraps the result in a React layout component. It copies over any attributes on the `body` tag, and inserts tags inside `head`, including running any scripts.\n\nWhen the user clicks a link, it will check your Vike routing rules. If the route has `proxyMode: wrapped`, it will make a request to Rails and do all of the above, this time on the client. If the link is to a Vike page with `proxyMode: false`, it will render that page instead.\n\nThe \"passthru\" proxy mode is an option of incremental migration. Passthru routes simply render whatever Rails returns. This lets you start building Vike/Bifrost pages without committing to the full wrapped experience.\n\n### Setting up Wrapped Proxy\n\n1. In Rails check for a `x-vite-proxy` (name configurable) header and skip rendering the layout, so Bifrost can render the layout, enabling seamless page transitions. Also return which layout the page needs + any layout config/props via another header.\n2. In Bifrost, setup a page with `proxyMode: wrapped` and configure the following:\n   1. `getLayout` is a function to pull layout name and properties from the headers returned by Rails.\n   2. `layoutMap` maps layout names to layout components\n   3. `proxyHeaders` adds the `x-vite-proxy` (or other named header) to signal Rails you're coming from Bifrost.\n3. Move your navbar/layouts to be render-able via Bifrost\n4. (Optional) Setup your load balancer toggle traffic to Bifrost/Rails based on the `x-vite-proxy` header. This enables the frontend to hit Rails directly on client-side navigation, reducing overhead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falignable%2Fbifrost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falignable%2Fbifrost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falignable%2Fbifrost/lists"}