{"id":16957968,"url":"https://github.com/joshnuss/svelte-bridge","last_synced_at":"2025-03-22T13:32:23.551Z","repository":{"id":55833838,"uuid":"521462114","full_name":"joshnuss/svelte-bridge","owner":"joshnuss","description":"Use your Svelte components from React \u0026 Vue.","archived":false,"fork":false,"pushed_at":"2022-08-12T19:30:38.000Z","size":18,"stargazers_count":44,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-18T11:48:20.031Z","etag":null,"topics":["react","svelte","vite","vue"],"latest_commit_sha":null,"homepage":"","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/joshnuss.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}},"created_at":"2022-08-05T01:11:43.000Z","updated_at":"2025-02-09T17:36:17.000Z","dependencies_parsed_at":"2022-08-15T07:40:11.996Z","dependency_job_id":null,"html_url":"https://github.com/joshnuss/svelte-bridge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fsvelte-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fsvelte-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fsvelte-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fsvelte-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshnuss","download_url":"https://codeload.github.com/joshnuss/svelte-bridge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244963008,"owners_count":20539255,"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":["react","svelte","vite","vue"],"created_at":"2024-10-13T22:20:48.881Z","updated_at":"2025-03-22T13:32:23.292Z","avatar_url":"https://github.com/joshnuss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-svelte-bridge\n\nWrite Svelte components and use them from React \u0026 Vue.\n\nThis plugin generates wrapper components in `dist/react` and `dist/vue` at build time.\n\n## Setup\n\nInstall the package:\n\n```bash\npnpm install -D vite-plugin-svelte-bridge\n```\n\nAdd `react` and `vue` plugins to `vite.config.js`:\n\n```javascript\n// vite.config.js\nimport { defineConfig } from 'vite'\nimport { svelte } from '@sveltejs/vite-plugin-svelte'\nimport { react, vue } from 'vite-plugin-svelte-bridge'\n\nexport default defineConfig({\n  plugins: [ svelte(), react(), vue() ]\n})\n```\n\nUpdate `package.json`:\n\n1. Add `dist/react` and `dist/vue` to the `exports` section\n\n```javascript\n\"exports\": {\n  \".\": \"./dist/index.js\",\n  \"./react/*\": \"./dist/react/*\",\n  \"./vue/*\": \"./dist/vue/*\"\n}\n```\n\n2. Specify which components should be wrapped:\n\n```javascript\n\"bridge\": {\n  \"MyComponent\": \"src/lib/MyComponent.svelte\"\n}\n```\n\nRunning `vite build` will generate a `dist/react/MyComponent.jsx` and a `dist/vue/MyComponent.vue`.\n\n## Usage\n\n### React\n\nTo access a component from a React project, install the package:\n\n```bash\npnpm install -D my-svelte-lib\n```\n\nThen import the component from the `react/` folder:\n\n```jsx\n// in src/App.jsx\nimport MyComponent from 'my-svelte-lib/react/MyComponent.jsx'\n\nexport default function App() {\n  return \u003cMyComponent prop={42} onClick={() =\u003e alert('clicked')}/\u003e\n}\n```\n\n### Vue\n\nTo access a component from a Vue project, install the package:\n\n```bash\npnpm install -D my-svelte-lib\n```\n\nThen import the component from the `vue/` folder:\n\n```vue\n\u003c!-- in src/App.vue --\u003e\n\u003cscript setup\u003e\n  import MyComponent from 'my-svelte-lib/vue/MyComponent.vue'\n\u003c/script\u003e\n\n\u003ctemplate\u003e\n  \u003cMyComponent prop={42} @click=\"alert('clicked')\"/\u003e\n\u003c/template\u003e\n```\n\n## Caveats\n\nThe following features are not supported (yet?):\n\n- Slots\n- 2-way data binding\n- Types\n- Angular, Solid.js\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshnuss%2Fsvelte-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshnuss%2Fsvelte-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshnuss%2Fsvelte-bridge/lists"}