Skip to content

Allow passing in routerProps to <StartClient #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

devinrhode2
Copy link
Contributor

@devinrhode2 devinrhode2 commented Aug 23, 2023

Closes #96

When embedding a SolidStart app into a larger javascript app, users may need to customize the router source/integration, to avoid messing with the parent/host apps url. Users could use an in-memory based router, a search-param based router, hash-based router, etc.

PR Checklist

There aren't any existing tests for <StartClient. I think in the future it would be good to add a "solid-as-a-micro-frontend" example, and we could add a test which ensures that example app renders with searchParamIntegration

PR Type

  • Feature

What is the current behavior?

Use patch-package to pass in routerProps

What is the new behavior?

Users can customize router source/integration.

Other information

@devinrhode2 devinrhode2 force-pushed the allow-passing-routerProps-through-StartClient branch from 348b494 to 50c819e Compare August 23, 2023 19:47
@devinrhode2 devinrhode2 force-pushed the allow-passing-routerProps-through-StartClient branch from 50c819e to c7e4177 Compare August 23, 2023 19:55
@ryansolid
Copy link
Member

I think this is fine. Just wondering if similar options need to make it to server. I will merge as is and we will find out I guess.

@ryansolid ryansolid merged commit d43e46c into solidjs:main Aug 29, 2023
@devinrhode2
Copy link
Contributor Author

devinrhode2 commented Aug 30, 2023

For my use case, my Solid backend is only ever receiving requests for 100% normal path-based SolidStart urls.

When the Solid code renders in a browser, it will be search-param based (via searchParamIntegration).

Here's an example client side (no ssr) call flow:

  1. Load Next.js demo w/ url nextjs-demo.com/asdf/asdf?widgetUrl=${encodeURIComponent("solid-app.com/foo?paramA=a&paramB=b"}
  2. <FakeFrame href="solid-app.com/foo?paramA=a&paramB=b"
  3. fetch('solid-app.com/foo?paramA=a&paramB=b'
  4. Inject the html and scripts into the browser
  5. SolidStart uses searchParamIntegration('widgetUrl') to correctly hydrate

I did get hydration working with this approach

@devinrhode2 devinrhode2 deleted the allow-passing-routerProps-through-StartClient branch August 30, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support router integrations of solid-app-router
2 participants