First of all, apologies, this answer turned out to be rather long.
If you use RSA to sign your tokens, and the connecting client is a web browser, the client will never see RSA keys (public or private). This is because the client apparently does not need to check the validity of the JWT, only the server should do this. The client simply holds the JWT and shows it to the server when requested. Then the server checks its validity when viewing the token.
So why do you need a combined public / private key for JWT? Well, firstly, you do not need to use the public / private key algorithm.
You can sign a JWT with several different algorithms, RSA is one of them. Other popular signature options for your JWT are ECDSA or HMAC (the JWT standard also supports others ). HMAC, in particular, is not a public / private key scheme. There is only one key, a key that is used to sign and verify tokens. You can think of it as using the private key to sign and verify the JWT. I am by no means an expert in this matter, but here are the conclusions that I came to after my recent research:
Using HMAC is nice because it is the fastest option. However, in order to test JWT, you need to give someone one key that does everything. Sharing this key with someone else means that this person can now also sign tokens and pretend to be you. If you are creating several server-side applications that everyone should be able to test your JWTs, you may not want each application to be able to sign tokens as well (different programmers may support different applications, sharing the possibility of signing with more people is a security risk and etc.). In this case, it is better to have one strictly controlled private key (and one application that performs the signature), and then share the public key with other people to enable them to check tokens. Here, the private key is used to sign tokens, and the public key is used to verify them. In this case, you will want to choose RSA or ECDSA.
For example, you may have an ecosystem of applications that all connect to the same database. To enter the system, each application sends people to one, dedicated application "login". This application has a private key. Another application may verify that the person is logged in using the public key (but they cannot log in).
My research indicates that RSA is the best option for most JWT applications in this scenario. This is because, theoretically, your application will often check tokens. RSA is much faster than ECDSA when tested. ECDSA is primarily good because the keys are smaller. This makes it better for HTTPS certificates, because you need to send the public key to the client’s browser. However, in the JWT script, the keys remain on the server, so the storage size is not specified, and the verification speed is more important.
Bottom line: if you are creating a small application without a few small “micro-service applications” / you are the only developer, perhaps choose HMAC to encrypt your keys. Otherwise, probably choose RSA. Again, I'm not an expert, just someone who recently googled this topic, so grab this with a little salt.