I have a modal on my page (Next.js) that is triggered clicking a button:
<button type='button' onClick={() => setOpen(true)}>
The modal:
<Modal
id='demo'
show={isOpen}
onClose={() => setOpen(false)}
>
The modal is hidden by default. And I would like to send a link to client. When the client clicks on the link, they will be brought to the page with the modal opened. Is it possible to do this? How? Thank you very much.
I tried to put the id in the URL like: https://example.com/contact#demo , but no luck. I was thinking about using the query mark(?), but can’t figure how it would work.
2
Answers
if NextJS is with react-dom then you can use
useSearchParams
fromreact-router-dom
you could detect the
referrer
which tells you from which link the client was navigated to your page. you can definegetServerSideProps
then based on
referred
propYou could handle this in client side as well
using
referred
state value