Skip to content

Using the parse 'methods' outside the hook #348

Answered by franky47
r1chm8 asked this question in Q&A
Discussion options

You must be logged in to vote

While there there is nothing server or client-specific about parsers, the fact that they're imported from next-usequerystate -- which is a client-only import -- makes it forbidden to call functions on them:

Error: Cannot access parseAsInteger.parse on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.

It would be possible I guess to export the parsers in a separate, non-'use-client' file, that can be imported on the server and the client (eg: import { parseAsInteger } from 'next-usequerystates/parsers').

Assuming we're having no import issues, there would still be a bit of data massaging to get to the same value as what …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@r1chm8
Comment options

@franky47
Comment options

@r1chm8
Comment options

@franky47
Comment options

Answer selected by r1chm8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants