Replies: 1 comment 6 replies
-
I guess it depends on how you want to organize it. The nice thing is that the API for Remix itself is pretty straightforward:
(among other things, but we'll just stick with those three) So one level of abstraction would be having your package export those, and then have each app create the routes as needed. Something like this: // /app/routes/sign-up.tsx
export {default, loader, action} from '@my-org/pre-built-remix/sign-up'` That's it. That's the module. Naturally, you could make it so you export components and functions which are used in the modules, like so: // /app/routes/sign-up
import {SignUpForm, signupLoader, signupAction} from '@my-org/pre-built-remix/sign-up'
export async function loader(args) {
// Do other stuff here
return {signUpResult: await signupLoader(args)}
}
export async function action(args) {
// Do other stuff here
return {signUpResult: await signupAction(args)}
}
export default function SignUp() {
return (<div>
<SignUpForm />
</div>)
} You could take it even further the other direction by exporting a function which is used in the Lots of options, I don't think there's an official "line in the sand" - it depends on how willing your consumers are to adopt the approach you choose. If it's a package intended to tightly unify an individual org, then you could probably get away with a lot. If you're looking for broad adoption, then people will likely prefer for you to give small building blocks that they can intersperse in their own application logic and component tree. Hopefully this gives you some ideas. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm failing to create a mental model for publishing reusable functionality as an npm package.
Let's say I have a set of routes and React components that implement an auth, that should be reused across multiple apps.
It may include sign-up, password reset, sign-out, etc... The typical boilerplate many apps have.
This would be opinionated, and specific, so not really something like remix-auth.
Think org-specific or, perhaps, service-specific set of functionality that goes hand-in-hand together.
What's the best way to achieve that?
Where's the "line in the sand" of the contract between the publisher and consumer?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions